Closed TolgaAcar closed 4 years ago
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;
member
member_id
first_name
last_name
address
email
pass
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;
food_container
container_id
name
type
lng
lat
weight
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;
credit_card
card_number
full_name
cvv_number
expiration_date
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;
fills
amount
food_type
commet
fills_card_number
fills_member_id
fills_container_id
DatabaseTables.txt
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
), KEYmember_id
(member_id
) /!80000 INVISIBLE /, CONSTRAINTmember_id
FOREIGN KEY (member_id
) REFERENCESmember
(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
), KEYfills_card_number
(card_number
), KEYfills_member_id
(member_id
), CONSTRAINTfills_card_number
FOREIGN KEY (card_number
) REFERENCEScredit_card
(card_number
) ON UPDATE CASCADE, CONSTRAINTfills_container_id
FOREIGN KEY (container_id
) REFERENCESfood_container
(container_id
) ON UPDATE CASCADE, CONSTRAINTfills_member_id
FOREIGN KEY (member_id
) REFERENCEScredit_card
(member_id
) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;DatabaseTables.txt