When a database key is created from a combination of two or more columns, the key is called a composite key. Each column may not be unique by itself within the database table but when combined with the other column(s) in the composite key, the combination is unique.
The following data is taken from the Google DFP Report API example source code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Or to modify an existing table:
Which will generate these keys:
1 2 3 4 5 6 7 8 9 10 11 12
Don’t let the color highlighting above fool you. date is another column in the table.
Now, if you try to rerun the same import against existing data, you’ll receive the following error message:
Duplicate entry '2014-01-14-83243539-236269939-15980539-32298017059-67086499-1643' for key 'composite_dfp'
A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a new row with a key value that matches an existing row. This constraint does not apply to NULL values except for the BDB storage engine. For other engines, a UNIQUE index allows multiple NULL values for columns that can contain NULL. Document Source
1. Go to the edit window for the table you’re working on
2. Add a new index in the far-left screen by clicking on the new index row and giving the new index a name
3. Select the UNIQUE type
4. Check all of the corresponding index columns to the right