A Gentle Introduction to
CREATE and DROP
How to create tables, indexes, views and other things. How to get rid of them.
Composite primary key, foreign key
Composite primary key
the primary key is made up of more than one field
one (or more) field from this table relates to the primary key of another table
We must explicitly specify that the components of the key are not NULL.
The foreign key statements don't do anything - referential integrity is not enforced.
Possible error messages:
Error 1171 All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead
CREATE TABLE t_holiday (yr INTEGER NOT NULL ,country VARCHAR(20) NOT NULL ,comment VARCHAR(80) ,FOREIGN KEY(country) REFERENCES cia(name) ,PRIMARY KEY (yr,country) )