0
我想知道在數據庫中創建單獨的table
正確的timestamp
是否是好的做法。從數據庫中的實際表中分離時間戳
我有一個數據庫有多個表使用時間戳 - 所有6個相同的字段 - 並想知道,而不是重複這些列,我可以包括我的時間戳表foreign key
。
這是我在簡化例如:
用戶表:
+----+-----------+-----------------------+
| ID | timestamp | username |
+----+-----------+-----------------------+
| 1 | 1 | [email protected] |
+----+-----------+-----------------------+
| 2 | 2 | [email protected] |
+----+-----------+-----------------------+
| 3 | 3 | [email protected] |
+----+-----------+-----------------------+
| 4 | 4 | [email protected] |
+----+-----------+-----------------------+
| 5 | 4 | [email protected] |
+----+-----------+-----------------------+
Orders表
+----+-----------+--------------------+--------+
| ID | timestamp | ordersBlob | userid |
+----+-----------+--------------------+--------+
| 1 | 6 | some text | 1 |
+----+-----------+--------------------+--------+
| 2 | 7 | more text | 1 |
+----+-----------+--------------------+--------+
| 3 | 8 | no text | 2 |
+----+-----------+--------------------+--------+
| 4 | 9 | irony poining text | 3 |
+----+-----------+--------------------+--------+
| 5 | 10 | paradox text | 4 |
+----+-----------+--------------------+--------+
時間戳表
+----+-----------+-----------+------------+------------+
| ID | createdOn | createdBy | modifiedOn | modifiedBy |
+----+-----------+-----------+------------+------------+
| 1 | 20170616 | 1 | | |
+----+-----------+-----------+------------+------------+
| 2 | 20170621 | 3 | 20170621 | 2 |
+----+-----------+-----------+------------+------------+
| 3 | 20160512 | 4 | | |
+----+-----------+-----------+------------+------------+
| 4 | 20160512 | 4 | 20160516 | 3 |
+----+-----------+-----------+------------+------------+
| 5 | 20160101 | 2 | | |
+----+-----------+-----------+------------+------------+
| 6 | 20160102 | 2 | 20160103 | 3 |
+----+-----------+-----------+------------+------------+
| 7 | 20160103 | 4 | | |
+----+-----------+-----------+------------+------------+
| 8 | 20160104 | 1 | | |
+----+-----------+-----------+------------+------------+
| 9 | 20160105 | 5 | | |
+----+-----------+-----------+------------+------------+
| 10 | 20160106 | 1 | 20160106 | 1 |
+----+-----------+-----------+------------+------------+
這些表僅作爲示例。那樣可以做那樣的事情。如果您能提供反例和原因,您不會那樣做,請提供。
希望這不是很多意見的基礎。
我沒有想到它會減慢我的手術。很好記住!謝謝 – Chax