Thanks Pat Phelan for the good explaination.
Quote:
|
I'm a strong believer in surrogate keys
|
I am a believer too, that's why both my strong entities use meaningless surrogate keys:
Strong_Entity1(se1_id(PK))
Strong_Entity2(se2_id(PK))
My issue now is more about weak entities...those between 2 strong entities.
As far as possible, I want to avoid creating new surrogate key (new table field/column) for weak entities since their foreign keys are already meaningless...and won't be changed by some monkeys. (Is this thinking of mine right ?)
I have thought of a way to
clearly determine whether to create new surrogate key for weak entities or not :
As long as I don't use ON DELETE/UPDATE SET NULL / SET DEFAULT (this means you use ON DELETE/UPDATE CASCADE/RESTRICT/NO ACTION), it is ok to use se1_id(PK), se2_id(PK) as the primary key and do not need to create a new meaningless primary key for the weak entity.
But if you have ON DELETE/UPDATE SET NULL / SET DEFAULT, you have to create a new surrogate key for the weak entity's own use. This is because if you use se1_id(PK), se2_id(PK) as its primary key, SET NULL/SET DEFAULT on either side of the referencial integrity constraint will cause the record to be not unique in the weak entity table.
Correct me if I am wrong.