MySQL Database

By bre09 ·
I am trying to create an orders table which has three primary keys which are related to two different tables. The problem being is I can only assign one of the required keys as a Primary key. Can anyone tell my how to correctly do this?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

You can only have one primary key, Make

by Tony Hopkinson In reply to MySQL Database

the other's Unique Keys.

Strange thing to do it's almost as if you have things bass ackwards.

Table1 with a prinary key
Table2 witha primary key

Table3 with a primary key and foreign keys, linked to Table1 and Table2

Would be a normal approach.

Collapse -

Foreign keys

by dballiu In reply to MySQL Database

Hi, I guess you mean to have one primary key for your orders table plus two foreign keys pointing to the related tables.

Related Discussions

Related Forums