User:Temporitron/sb

CREATE TABLE customer (	id int NOT NULL AUTO_INCREMENT PRIMARY KEY,	name varchar (64) NOT NULL ) TYPE=INNODB;

CREATE TABLE contact_type (	id int NOT NULL AUTO_INCREMENT PRIMARY KEY,	contact_type varchar(8) NOT NULL ) TYPE=INNODB;

CREATE TABLE contact (	customer_id int NOT NULL REFERENCES customer (id),	contact_type_id int NOT NULL REFERENCES contact (id),	contact_value varchar (64) NOT NULL,	PRIMARY KEY (customer_id, contact_type_id) ) TYPE=INNODB;

INSERT INTO customer (id, name) VALUES (1, 'Joe Consumer'), (2, 'Sally Consumer');

INSERT INTO contact_types (id, contact_type) VALUES (1, 'fax'), (2, 'phone'), (3, 'email');

INSERT INTO contact (customer_id, contact_type_id, contact_value) VALUES (1, 2, '1-234-5678901'), (1, 3, 'joe@consumer.com'), (1, 1, '1-234-5678902'),	(2, 1, '1-234-5678903');