Re: multi2 [message #765 is a reply to message #764] |
Wed, 11 April 2007 11:59 |
AJM
Messages: 2368 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
Every table in a relational database is supposed to have a primary key. EMP_PHONE should therefore have a primary key of EMPLOYEE_ID + PHONE_ID which will prevent the same PHONE_ID from being added to the same EMPLOYEE_ID more than once. This will also allow an EMPLOYEE_ID to have more than one PHONE_ID, and allow a PHONE_ID to be shared by more than one EMPLOYEE_ID.
When you want to change an employee's phone number using this design what you have to do is DELETE the old one before INSERTING the new one. Some DBMS engines do not allow primary keys to be updated (which is why technical primary keys were invented in the first place), so this is the way to do it. The Radicore framework follows this traditional convention by not allowing any part of a primary key to be updated in its default processing. However, it is possible to update a primary key with custom code as I mentioned in a previous post.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|