SET collection types
- The elements contain no duplicate values.
- The elements have no specific order associated with them.
CREATE TABLE employee
(
name CHAR(30),
address CHAR (40),
salary INTEGER,
dependents SET(VARCHAR(30) NOT NULL)
);
A query against the dependents column for any given row returns the names of all the dependents of the employee. In this case, SET is the correct collection type because the collection of dependents for each employee should not contain any duplicate values. A column that is defined as a SET ensures that each element in a collection is unique.
CREATE TABLE employee
(
name CHAR(30),
address CHAR (40),
salary INTEGER,
dependents SET(ROW(name VARCHAR(30), bdate DATE) NOT NULL)
);
Each element of a collection from the dependents column contains values for the name and bdate. Each row of the employee table contains information about the employee and a collection with the names and birthdates of the employee's dependents. For example, if an employee has no dependents, the collection for the dependents column is empty. If an employee has 10 dependents, the collection should contain 10 elements.