Hjælp til foreign key Part 2
Havde igår denner tråd kørendehttp://www.eksperten.dk/spm/537131
Her fil jeg hjælp til at komme vidre, men jeg har stadigvæk nogle tabeller jeg ikke kan lave…
Jeg vedlægger her samtlige tabeller fra min db, både dem som virker og dem som ikke virker.
CREATE TABLE ATTENDEE (
Attendee_id INT UNSIGNED NOT NULL,
Phone TINYINT UNSIGNED,
Street VARCHAR(30),
Street_no TINYINT UNSIGNED,
Apt_no VARCHAR(10),
City VARCHAR(30),
Zip TINYINT UNSIGNED,
Country VARCHAR(30),
PRIMARY KEY (Attendee_id))
TYPE = Innodb;
CREATE TABLE WHOLESALE (
CVR TINYINT UNSIGNED NOT NULL,
Attendee_id INT UNSIGNED NOT NULL,
Wholesale_name VARCHAR(30),
Description VARCHAR(200),
INDEX Attendee_id_ix (Attendee_id),
PRIMARY KEY (CVR),
FOREIGN KEY (Attendee_id) REFERENCES ATTENDEE(Attendee_id))
TYPE = Innodb;
CREATE TABLE CUSTOMER (
Customer_id INT UNSIGNED NOT NULL,
Contact_person VARCHAR(30),
Attendee_id INT UNSIGNED NOT NULL,
INDEX Attendee_id_ix (Attendee_id),
PRIMARY KEY (Customer_id),
FOREIGN KEY (Attendee_id) REFERENCES ATTENDEE(Attendee_id))
TYPE = Innodb;
CREATE TABLE EMPLOYEE_TYPE (
Type_id TINYINT UNSIGNED NOT NULL,
Type VARCHAR(30),
PRIMARY KEY (Type_id))
TYPE = Innodb;
CREATE TABLE EMPLOYEE (
SSN TINYINT UNSIGNED NOT NULL,
First_name VARCHAR(30),
Middel_name VARCHAR(30),
Last_name VARCHAR(30),
Sex CHAR,
Field_of_work VARCHAR(30),
Start_date DATE,
Time_rate DOUBLE UNSIGNED,
Email VARCHAR(30),
Type_id TINYINT UNSIGNED NOT NULL,
Attendee_id INT UNSIGNED NOT NULL,
INDEX Type_id_ix (Type_id),
INDEX Attendee_id_ix (Attendee_id),
PRIMARY KEY (SSN),
FOREIGN KEY (Type_id) REFERENCES EMPLOYEE_TYPE(Type_id),
FOREIGN KEY (Attendee_id) REFERENCES ATTENDEE(Attendee_id))
TYPE = Innodb;
CREATE TABLE VALIDATION (
SSN TINYINT UNSIGNED NOT NULL,
Hash_password TEXT NOT NULL,
Random_number INT
INDEX SSN_ix (SSN),
PRIMARY KEY (SSN, Hash_password),
FOREGIN KEY (SSN) REFERENCES EMPLOYEE(SSN))
TYPE = INNODB;
CREATE TABLE PROJECT (
Project_id INT UNSIGNED NOT NULL,
Project_name VARCHAR(30),
Project_start DATE,
Project_end DATE,
Customer_id INT UNSIGNED NOT NULL,
INDEX Customer_id_ix (Customer_id),
PRIMARY KEY (Project_id),
FOREIGN KEY (Customer_id) REFERENCES CUSTOMER(Customer_id))
TYPE = Innodb;
CREATE TABLE PROJECT_PART (
Project_part_id INT UNSIGNED NOT NULL,
Project_assignment VARCHAR(30),
Location VARCHAR(30),
Start DATE,
End DATE,
Project_id INT UNSIGNED NOT NULL,
Supervisor_id INT UNSIGNED NOT NULL,
INDEX Project_id_ix (Project_id),
INDEX Supervisor_id_ix (Supervisor_id),
PRIMARY KEY (Project_part_id),
FOREIGN KEY (Project_id) REFERENCES Project(Project_id),
FOREIGN KEY (Supervisor_id) REFERENCES EMPLOYEE(Employee_id))
TYPE = Innodb;
CREATE TABLE WORKS_ON (
SSN TINYINT UNSIGNED NOT NULL,
Project_part_id INT UNSIGNED NOT NULL,
Start TIME,
End TIME,
Date DATE,
PRIMARY KEY (SSN,Project_part_id),
FOREIGN KEY (SSN) REFERENCES EMPLOYEE(SSN),
FOREIGN KEY (Project_part_id) REFERENCES Project_part(Project_part_id))
TYPE = Innodb;
CREATE TABLE ASSETS_AND_LIABILITIES (
Audit_id INT UNSIGNED NOT NULL,
Date DATE,
Price DOUBLE,
Due DATE,
Is_paid_date DATE,
PRIMARY KEY (Audit_id))
TYPE = Innodb;
CREATE TABLE BILL (
Bill_id INT UNSIGNED NOT NULL,
Audit_id INT UNSIGNED NOT NULL,
Project_id INT UNSIGNED NOT NULL
INDEX Audit_id_ix (Audit_id),
INDEX Project_id_ix (Project_id),
PRIMARY KEY (Bill_id),
FOREIGN KEY (Audit_id) REFERENCES ASSETS_AND_LIABILITIES(Audit_id),
FOREIGN KEY (Project_id) REFERENCES Project(Project_id))
TYPE = Innodb;
CREATE TABLE PRODUCT_PURCHASE (
Invoice_id INT UNSIGNED NOT NULL,
Quantity INT UNSIGNED
Product_name VARCHAR(30),
Audit_id INT UNSIGNED NOT NULL,
CVR TINYINT UNSIGNED NOT NULL,
INDEX Audit_id_ix (Audit_id),
INDEX CVR_ix (CVR),
PRIMARY KEY (Bill_id),
FOREIGN KEY (Audit_id) REFERENCES ASSETS_AND_LIABILITIES(Audit_id),
FOREIGN KEY (CVR) REFERENCES WHOLESALE (CVR))
TYPE = Innodb;
Det er PROJECT_PART, WORKS_ON, VALIDATIN og PRODUCT_PURCHAES.
Så jeg håber på der er en venlige sjæle vil hjælpe mig med at komme vidre :)