Моделирование базы данных для слабой сущности
У меня есть 2 таблицы в моей базе данныхorders
а такжеorderHistory
.
----------------- -----------------------
| orders | | orderHistory |
----------------- -----------------------
| orderID (PK) | | historyLineID (PK) |
| orderDate | | status |
| price | | quantity |
----------------- -----------------------
Сейчасorder
может иметь несколькоhistory lines
, Тем не менее,history line
не может существовать самостоятельно. Я слышал, это называется слабой сущностью и, следовательно,PK отorders
должен быть частьюPK столаorderHistory
.
Questions
Is this really a correct weak entity relationship? Is there other ways to identify them? Should I add the PK of tableorder
to table orderHistory
and make it a composite primary key?
In case I decide to add a new record to orderHistory
, how will I add a new composite key? (orderID
is available from table orders
, but historyLineID
should be auto incremented.)
What if I decide to model this as a normal One-To-Many relationship where orderID
is added as a foreign key only instead? what are the cons of doing so?
Will ignoring Weak entities at all cause any problems later in a design provided all tables are in 3rd normal form?
Note
И то и другоеorderID
& Амп;historyLineID
суррогатные ключи.
Заранее спасибо.