Hi guys I’m trying to implement database models using mysql. One thing struck me when I was trying to convert E/R database model to Relational DB model. So here’s the question.
*Please keep in mind that ‘Relationship’ from ERDB and ‘Relation’ from RDB are different.
As far as I know, the followings are the standard when converting ER entity sets and relationships to RDB relations.
Entity Sets : Simply use all the attributes as columns (key attributes become the primary key). Relationships (Many-Many) : Use key attributes (from both entity sets) as table columns.
So this means that when I’m trying to create a table for any relationship, I have to bring the key(keys) from existing tables (like a foreign key).
But when I looked up, almost everyone told me I shouldn’t use a referenced foreign key as a primary key for that table (because foreign keys should allow non-unique values). This doesn’t make sense because all kinds of relationship have to reference the keys from entity sets (relations).
I’m totally confused, somebody please help me!