Last answered:

19 Jun 2024

Posted on:

24 Sept 2022

3

Resolved: 2 columns as primary key

what if I want to make the primary key for 2 columns together
how can I name the primary key for the 2 named columns and how can we create a relation between them





like





     (Primary key name for 2 columns)

I Purchase num column I Sales column I
I                                      I                         I
I                                      I                         I
I                                      I                         I

3 answers ( 1 marked as helpful)
Instructor
Posted on:

26 Sept 2022

2

Hi Peter!
Thanks for reaching out.

The syntax for defining a composite primary key is:
PRIMARY KEY(column_1, column_2).
In this case: PRIMARY KEY(Purchase_num_column, Sales_column). The names of the columns should not contain a space. Please, use an underscore for example.

Hope this helps.
Best,
Tsvetelin

Posted on:

26 Sept 2022

0

Thank you

Posted on:

19 Jun 2024

1

but the instructor said that you can have one and Only one primary Key, then how come that we can have 2 fields as a primiary keys, I'm lost 


Submit an answer