CREATE TABLE `client` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`full_name` varchar(255),
`personal_account` int,
`login` varchar(255),
`password` varchar(255)
);
CREATE TABLE `admin` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`access_id` int,
`full_name` varchar(255),
`login` varchar(255),
`password` varchar(255)
);
CREATE TABLE `access` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`name` varchar(255)
);
CREATE TABLE `bank_account` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`account` int
);
CREATE TABLE `products` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`id_admin` int,
`name` varchar(255),
`price` int,
`size` varchar(255),
`colour` varchar(255),
`location` varchar(255)
);
CREATE TABLE `buy_list` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`id_products` int,
`id_client` int,
`id_bank_account` int,
`date` datetime
);
ALTER TABLE `client` ADD FOREIGN KEY (`id`) REFERENCES `buy_list` (`id_client`);
ALTER TABLE `products` ADD FOREIGN KEY (`id`) REFERENCES `buy_list` (`id_products`);
ALTER TABLE `products` ADD FOREIGN KEY (`id_admin`) REFERENCES `admin` (`id`);
ALTER TABLE `buy_list` ADD FOREIGN KEY (`id_bank_account`) REFERENCES `bank_account` (`id`);
ALTER TABLE `access` ADD FOREIGN KEY (`id`) REFERENCES `admin` (`access_id`);