Database design is not good, allocation is very important.

Source: Internet
Author: User

Database design is not good, allocation is very important.

Previously encountered a demand, is now abstracted for each member can add some tasks for themselves

Naturally, the table is very well designed

Table 1:taskid, UserID, Content, status, Createtime

Later added demand, to the administrator can add tasks for members

Naturally, add three more tables.

Table 2:staskid, content, Createtime
Table 3:allotid, Staskid, userid, Isdel distribution table
Table 4:id, Staskid, UserID, Status complete State table

Then table 2, table 3, table 4 through a variety of joins into the form of table 1, and then through the Union as a table,

Finally found that many of the previous numerical statistics and so on to change, all because the back of a staskid and different.


And then think about it, if we were to design it from the start

Table 5:taskid, type, content, createtime (more than one type, which distinguishes whether the member created it himself or created by the administrator)
Table 3:allotid, TaskID, userid, Isdel distribution table
Table 4:id, TaskID, UserID, Status complete State table

In this case, the extensibility will be better ...

Database design is not good, allocation is very important.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.