simpsons
11-29-2007, 12:51 PM
I'm having trouble with one query in particular. I have created five tables, and now I want to add some foreign keys to the tables. However when I add code for the constraints, an error message pops up. Due to this, I have used the 'Alter' command and then the 'Add' command as follows:
ALTER TABLE ViewingAppointment
ADD CONSTRAINT ViewingAppointment_AppointmentCode_pk PRIMARY KEY (AppointmentCode),
ADD CONSTRAINT ViewingAppointment_PotentialBuyerCode_fk FOREIGN KEY (PotentialBuyerCode) REFERENCES PotentialBuyer (PotentialBuyerCode),
ADD CONSTRAINT ViewingAppointment_HouseCode_fk FOREIGN KEY (HouseCode) REFERENCES SaleProperty (HouseCode),
ADD CONSTRAINT ViewingAppointment_StaffName_fk FOREIGN KEY (StaffName) REFERENCES StaffMember (StaffName));
An error message is still popping up, this time saying 'syntax error in field definition'. Any help would be appreciated.
Another thing I was wondering. I want to find out the number of properties that has been sold for each property type.
To do this would I need the GROUP BY command?
Thank you.
ALTER TABLE ViewingAppointment
ADD CONSTRAINT ViewingAppointment_AppointmentCode_pk PRIMARY KEY (AppointmentCode),
ADD CONSTRAINT ViewingAppointment_PotentialBuyerCode_fk FOREIGN KEY (PotentialBuyerCode) REFERENCES PotentialBuyer (PotentialBuyerCode),
ADD CONSTRAINT ViewingAppointment_HouseCode_fk FOREIGN KEY (HouseCode) REFERENCES SaleProperty (HouseCode),
ADD CONSTRAINT ViewingAppointment_StaffName_fk FOREIGN KEY (StaffName) REFERENCES StaffMember (StaffName));
An error message is still popping up, this time saying 'syntax error in field definition'. Any help would be appreciated.
Another thing I was wondering. I want to find out the number of properties that has been sold for each property type.
To do this would I need the GROUP BY command?
Thank you.