简体   繁体   中英

Adding new table or extending a table

I have three transaction tables in which user can update the status of a transaction. These tables captures the user details, data-time etc when the status was last updated.

I have a requirement which says the if a user updates the status of transaction to 'X' , those transactions should be picked the next day. Now the problem is.. if a user 'A' updates the status to 'X', the table will capture the user 'A' details, now if user 'B' changes the status from 'X' to 'Y', the table will capture the user 'B' details (who updated the status last) and user 'A' details will be lost. The next day I cannot pick that transaction since the status is changed.

Is it better to add a new table with columns containing status, and user details ? A record will be inserted in it when someone changes the status to 'X'. Or it is better to new columns in the existing transaction tables to capture the user details when the status is updated to 'X' ?

-------------------------
Existing Table  design
-------------------------
------------------------------------------------------------------------
Key | Status | User name | User ID | Update_Dt |Other Columns.........
-------------------------------------------------------------------------
1   |    Y   |      B    |    2    |  2013-01-10


-------------------------
Adding new Table
-------------------------
------------------------------------------------
Key | Status | User name | User ID | Update_Dt |
------------------------------------------------
1   |    X   |      A    |     1   |  2013-01-10

OR

----------------------------------
Extending Existing Table  design
---------------------------------
--------------------------------------------------------------------------------------
Key| Status|User_name|User_ID|Update_Dt|X_Stat_User_Name|X_Stat_User_ID| X_Stat_Upd_Dt|other columns....
---------------------------------------------------------------------------------------
1  |   Y   |   B     |    2  |2013-01-10|    A          |       1      | 2013-01-10 

I would add another table. This also has the advantage that you can see the history of the transactions.

Trust me - 'they' say they don't need it someday they will come to you and 'This value is wrong. Who changed it?'

I would suggest to add another table call Transaction where you would had log to it . So it could be more easy to get all the modification that have been done on it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM