我如何改进我的数据库?

时间:2017-06-29 23:54:39

标签: mysql sql

我想帮助改进这个数据库。我发现成人宠物和孩子通常重复相同的模式,但我不知道该怎么做,因为他们每个人都有自己的服务,以及家里有情境表。

表名:ContactInfo,Jobs,Children,Adults,Pets,Home,Contract,ServiceAdults,ServiceChildren,ServiceHome,ServicePets,Situation。

   **ContactInfo**
   contact_id (primary key) mediumint not null auto_increment
   first_name varchar(25) not null
   last_name varchar(25) not null
   phone varchar(10) not null
   email varchar(255) not null
   user_name varchar(25) not null (unique)
   password varchar(25) not null

   **Jobs**
   job_id (primary key) mediumint not null auto_increment
   summary   text
   contact_id (foreign key references ContactInfo) mediumint not null

   **Contract**
   contract_id (primary key) mediumint not null auto_increment
   job_id (foreign key references Jobs) mediumint not null
   contact_id (foreign key references ContactInfo) mediumint not null
   //Note: Unique(job_id, contact_id)

   **Children**
   child_id  (primary key) mediumint not null auto_increment
   numOfChildren tinyint
   special enum('false','true')
   start_age tinyint
   end_age tinyint
   job_id (Foreign key references Jobs) mediumint not null

   **ServiceChildren**
   service_id (primary key) mediumint not null auto_increment
   service enum('babysit','tutor')
   child_id (foreign key references Children) mediumint not null

   **Adults**
   adult_id  (primary key) mediumint not null auto_increment
   numOfAdults tinyint
   special enum('false','true')
   start_age tinyint
   end_age tinyint
   job_id (Foreign key references Jobs) mediumint not null

   **ServiceAdults**
   service_id (primary key) mediumint not null auto_increment
   service enum('watch','travel')
   adult_id (foreign key references Adults) mediumint not null

   **Pets**
   pet_id  (primary key) mediumint not null auto_increment
   numOfPets tinyint
   special enum('false','true')
   start_age tinyint
   end_age tinyint
   job_id (Foreign key references Jobs) mediumint not null

   **ServicePets**
   service_id (primary key) mediumint not null auto_increment
   service enum('dog','cat','fish','bird')
   pet_id (foreign key references Pets) mediumint not null

   **Home**
   home_id  (primary key) mediumint not null auto_increment
   job_id (Foreign key references Jobs) mediumint not null

   **ServiceHome**
   service_id (primary key) mediumint not null auto_increment
   service enum('cook','clean', 'lawn')
   home_id (foreign key references Home) mediumint not null

   **Situation**
   situation_id (primary key) mediumint not null auto_increment
   service enum('visit','live in')
   home_id (foreign key references Home) mediumint not null

0 个答案:

没有答案