SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS `user`;
DROP TABLE IF EXISTS `property`;
DROP TABLE IF EXISTS `operating`;
DROP TABLE IF EXISTS `budget`;
DROP TABLE IF EXISTS `wish`;
SET FOREIGN_KEY_CHECKS = 1;
CREATE TABLE `user` (
`id` char(12) NOT NULL,
`username` char(20) NOT NULL,
`descriptin` varchar NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `property` (
`id` char(1) NOT NULL,
`account` char(18) NOT NULL,
`balance` float(8) NOT NULL,
`uid` char(12) NOT NULL,
PRIMARY KEY (`id`, `uid`)
);
CREATE TABLE `operating` (
`id` char(12) NOT NULL,
`type` bool NOT NULL,
`account` float(8) NOT NULL,
`uid` char(12) NOT NULL,
`pid` char(1) NOT NULL,
PRIMARY KEY (`id`, `uid`, `pid`)
);
CREATE TABLE `budget` (
`id` char(12) NOT NULL,
`schedule` float(8) NOT NULL,
`uid` char(12) NOT NULL,
PRIMARY KEY (`id`, `uid`)
);
CREATE TABLE `wish` (
`id` char(12) NOT NULL,
`description` varchar NOT NULL,
`finishtime` date NOT NULL,
`uid` char(12) NOT NULL,
PRIMARY KEY (`id`, `uid`)
);
ALTER TABLE `property` ADD FOREIGN KEY (`uid`) REFERENCES `user`(`id`);
ALTER TABLE `operating` ADD FOREIGN KEY (`uid`) REFERENCES `user`(`id`);
ALTER TABLE `operating` ADD FOREIGN KEY (`pid`) REFERENCES `property`(`id`);
ALTER TABLE `budget` ADD FOREIGN KEY (`uid`) REFERENCES `user`(`id`);
ALTER TABLE `wish` ADD FOREIGN KEY (`uid`) REFERENCES `user`(`id`);