Hello, I was wondering how i would create the Units table for this. Would i just set both Unit_ID and Customer_ID in the Units table as foreign keys or do i need to have a primary key like Customer_Unit_ID then have the two foreign keys?

Customers
Customer_ID Customer_Full_Name Contact_Name Address_1 Address_2 City Postal_Code State Phone Email
1
2
3
4
5
6
7
8
9
10
Customers_Units
Unit_ID Customer_ID
1 3
2 3
3 3
4 7
5 7
6 8
7 9
8 10
9 10
10 10
Units
Unit_ID Unit_Serial Number Stock_Receive_Date Scan_Out_Date
1
2
3
4
5
6
7
8
9
10

Recommended Answers

All 2 Replies

Member Avatar for diafol

if you want to join the Customers_Units to another table, then a PK can be useful. Also InnoDB creates one anyway, just that you won't have access to it if you don't declare it. PKs can be composite - i.e. more than one field. Each record in your link table needs to be unique, so why not have a PK?

Alright ill add the primary key so later i can use it with another table if i have to. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.