ZoologicalFooding / ZoologicalFooding-main

1 stars 0 forks source link

(Planning) As a developer, I would like to create a sample database so that components can be developed independently based on a common data model #1

Closed TolgaAcar closed 4 years ago

TolgaAcar commented 4 years ago

SQL codes for creating database on MySql.

Sql codes can be found at attachment.

CREATE TABLE member ( member_id int(11) NOT NULL AUTO_INCREMENT, first_name varchar(45) NOT NULL, last_name varchar(45) NOT NULL, address varchar(70) DEFAULT NULL, email varchar(45) NOT NULL, pass varchar(45) NOT NULL, PRIMARY KEY (member_id) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE food_container ( container_id int(11) NOT NULL AUTO_INCREMENT, name varchar(45) NOT NULL, type varchar(45) DEFAULT NULL, lng int(11) DEFAULT NULL, lat int(11) DEFAULT NULL, address varchar(75) DEFAULT NULL, weight double DEFAULT NULL, PRIMARY KEY (container_id) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE credit_card ( card_number int(11) NOT NULL, full_name varchar(75) NOT NULL, cvv_number int(11) NOT NULL, expiration_date date NOT NULL, member_id int(11) NOT NULL, PRIMARY KEY (card_number), KEY member_id (member_id) /!80000 INVISIBLE /, CONSTRAINT member_id FOREIGN KEY (member_id) REFERENCES member (member_id) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE fills ( amount varchar(45) DEFAULT NULL, food_type varchar(45) DEFAULT NULL, commet varchar(75) DEFAULT NULL, container_id int(11) NOT NULL, card_number int(11) NOT NULL, member_id int(11) NOT NULL, PRIMARY KEY (container_id,member_id), KEY fills_card_number (card_number), KEY fills_member_id (member_id), CONSTRAINT fills_card_number FOREIGN KEY (card_number) REFERENCES credit_card (card_number) ON UPDATE CASCADE, CONSTRAINT fills_container_id FOREIGN KEY (container_id) REFERENCES food_container (container_id) ON UPDATE CASCADE, CONSTRAINT fills_member_id FOREIGN KEY (member_id) REFERENCES credit_card (member_id) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

DatabaseTables.txt