Member Avatar

I have 3 tables --Ticket_Lines (parent), Labour_Items (child), Part_Items (child).

Table Ticket_Lines has 2 primary keys (ticket_number & ticket_line_number)

I know that you cant have two seperate primary keys in one table so would this mean that ticket_number and ticket_line_number is a composite primary key?

if that is correct, is this the best way of defining a composite primary key?

CONSTRAINT PRIMARY KEY (ticket_number, ticket_line_number);

Thankyou

joyc123 commented: jew +0
thelove commented: tested +0
Re: SQL composite primary key 80 80

That is correct. PRIMARY KEY (column1, column2...) will create a primary key using the columns specified.

Be a part of the DaniWeb community

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