In SQL, a composite key is a combination of more than one column to identify a unique row in a table.
For example in invoice table each row is uniquely identified. Here Invoice no and Product ID forms the composite Key. Each Invoice have different products / one product should not be entered twice in same invoice.
| Invoice No | ProductId | Qnty_shpd | Discount |
| 153 | 66 | 3000 | 16.7 |
| 153 | 26 | 6000 | 16.7 |
| 153 | 91 | 6000 | 16.7 |
| 154 | 66 | 3000 | 16.7 |
| 154 | 26 | 6000 | 16.7 |
| 154 | 91 | 6000 | 16.7 |
In another example,
The chart below shows an example of a composite key.
- Employee_id and Project_id are primary keys in the related tables: employee and project.
- When Employee_id and Project_id are put into the Billable_hours table, they become foreign keys.
- Employee_id and Project_id are combined to make one composite key that would identify each instance of billable hours.
| table: Billable Hours | ||
| Employee ID | Project ID | Hours_Worked |
| 01 | 01 | 200 |
| 01 | 02 | 120 |
| 02 | 01 | 50 |
| 02 | 03 | 120 |
| 03 | 03 | 100 |
| 03 | 04 | 200 |








[...] The primary key for table is created by combining all of the foreign key fields. This is known as a composite key. [...]