Last answered:

26 Sept 2022

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

2 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

Submit an answer