MySQL Forums
Forum List  »  Quality Assurance

Using two tables for primary key
Posted by: Pepi Tsutsumanov
Date: September 23, 2011 06:37AM

Hello there,
I'm trying to understand the use of composite primary keys but I still don't get clear idea.
I have a database with one table in it holding information about different projects.
I need to have two columns acting as primary keys so when inserting data it does not complain for duplicates.
For example, I have columns called activity_id and project_id. The thing is that when I have one project inserted - the project_id will be all the same number, while the activities will be different. When more than one project is inserted it is vice versa - the first activity_id could be the same with the first activity from the second project, while the project_id will be different.
So my idea is if it is possible to use those two tables Activity_ID and Project_ID as primary keys so when there is duplicate in one of the fields the other is checked and if it's unique, the insert is successful.

Hopefully it is not confusing but I tried to explain it as clear as possible
Hope you can help me with this.
Thanks in advance guys.


Options: ReplyQuote

Written By
Using two tables for primary key
September 23, 2011 06:37AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.