Eroxl's Notes
Relational Model 1 (CPSC 304)

Suppose that we have a ternary relationship T between entity sets D, E, and F such that D has a key constraint and E has a key constraint and total participation; these are the only constraints.

D has attributes d1 and d2, with d1 being the key; E has attributes e1 and e2, with e1 being the key; and F has attributes f1 and f2, with f1 being the key. T has no descriptive attributes. All attributes are integers.

Write SQL statements that create tables corresponding to this information so as to capture as many of the constraints as possible. If you cannot capture some constraint, explain why.

CREATE TABLE D (
	d1 INTEGER PRIMARY KEY,
	d2 INTEGER
);

CREATE TABLE E (
	e1 INTEGER PRIMARY KEY,
	e2 INTEGER
);

CREATE TABLE F (
	f1 INTEGER PRIMARY KEY,
	f2 INTEGER
);

CREATE TABLE T (
	d1 INTEGER NOT NULL,
	e1 INTEGER NOT NULL,
	f1 INTEGER NOT NULL,
	
	PRIMARY KEY (d1, e1, f1),
	
	UNIQUE (e1, f1), -- (e,f) -> d
	UNIQUE (d1, f1), -- (d,f) -> e
	
	FOREIGN KEY (d1) REFERENCES D,
	FOREIGN KEY (e1) REFERENCES E,
	FOREIGN KEY (f1) REFERENCES F
);

The total participation of E can not be represented in SQL as any entity e E can participate in multiple relationships T. SQL does not allow expressing minimum cardinality constraints, (ie. 1) and therefore we can not represent it.