Give an example of a relation with a unique composite key. A composite key is when you can uniquely identify a row in the table with a combination of two columns in the table. For example, imagine the following table: TEACHER (LastName, FirstName, Department) Where the composite key is (LastName, Department) Another example is: APARTMENT (BuildingNumber, ApartmentNumber, NumberOfBedrooms, Rent) Where (BuildingNumber, ApartmentNumber) is a unique composite key.
Work Step by Step
It is possible that in a school, there will be several teachers who have the same last name. It would be unusual, however, for there to be teachers with the same name in the same department. That is why, In this table, we could use LastName and Department as a composite key. In an apartment complex, there could be several apartments called 1A. However, each building would only have one apartment called 1A. Therefore we could combine these into a composite key.