Getting this error when adding the parts table: Msg 8110, Level 16, State 0, Line 1 Cannot add multiple PRIMARY KEY constraints to table 'Service_Parts'. Getting similar errors for the other tables....The first 2 had no errors but the others have errors.........Here is the code which contains errors..... CREATE TABLE Service_Parts( Part_Number int NOT NULL, Service_ID VARCHAR(80), PRIMARY KEY (Service_ID), PRIMARY KEY (Part_Number), FOREIGN KEY (Part_Number ) REFERENCES Part(Part_Number), FOREIGN KEY (Service_ID) REFERENCES ServiceRecordCalender(Service_ID) ); ServiceRecordCalender Table: CREATE TABLE ServiceRecordCalender( Service_ID VARCHAR(80), DateCalled DATE, DateOfService DATE, Serial_Number int NOT NULL, Technician_ID int NOT NULL, PRIMARY KEY (Service_ID ), FOREIGN KEY (Technician_ID ) REFERENCES Technician(Technician_ID ), FOREIGN KEY (Serial_Number ) REFERENCES Appliance(Serial_Number ), FOREIGN KEY (DateOfService ) REFERENCES Technician(DateOfService ) ); Technician Table: CREATE TABLE Technician( Technician_ID int NOT NULL, DateOfService DATE, OrderParts VARCHAR(80), PRIMARY KEY (Technician_ID) );
Getting this error when adding the parts table: Msg 8110, Level 16, State 0, Line 1 Cannot add multiple PRIMARY KEY constraints to table 'Service_Parts'.
Getting similar errors for the other tables....The first 2 had no errors but the others have errors.........Here is the code which contains errors..... CREATE TABLE Service_Parts( Part_Number int NOT NULL, Service_ID VARCHAR(80), PRIMARY KEY (Service_ID), PRIMARY KEY (Part_Number), FOREIGN KEY (Part_Number ) REFERENCES Part(Part_Number), FOREIGN KEY (Service_ID) REFERENCES ServiceRecordCalender(Service_ID) ); ServiceRecordCalender Table: CREATE TABLE ServiceRecordCalender( Service_ID VARCHAR(80), DateCalled DATE, DateOfService DATE, Serial_Number int NOT NULL, Technician_ID int NOT NULL, PRIMARY KEY (Service_ID ), FOREIGN KEY (Technician_ID ) REFERENCES Technician(Technician_ID ), FOREIGN KEY (Serial_Number ) REFERENCES Appliance(Serial_Number ), FOREIGN KEY (DateOfService ) REFERENCES Technician(DateOfService ) ); Technician Table: CREATE TABLE Technician( Technician_ID int NOT NULL, DateOfService DATE, OrderParts VARCHAR(80), PRIMARY KEY (Technician_ID) );
Primary key is among one of the most important constraints in databases. A primary key is used to identify each record present in a table uniquely.
Step by step
Solved in 2 steps