开发者

Best practice for combining table data in MySQL?

I have a list of people in a table that are associated with one or more projects, presumably stored in another table. My question is, what would be the best practice for setting this up? Each project needs to have a post of its own, the same goes for the people 开发者_运维知识库as they all have various kind of data. How do I tie multiple project posts to one people post, and vice versa?


The is a pretty wide scope question and depends on exact requirements of the entity infrastructure to be represented in the relational database.

I would suggest you to go over a basics of Data Normalization and consider yourself which normalization form is optimal for your application.

  • Description of the database normalization basics
  • Normal forms
  • Introduction to Data Normalization: A Database "Best" Practice

If we stick simply with Projects and Participants I would go further with sollowing desing:

**PROJECTS**
ID
...

**PEOPLE**
ID
...


**PROJECT_PARTICIPANTS**
PROJECT_ID (FK PROJECTS)
PARTICIPANT_ID (FK PEOPLES)


I'd expect to see a column that allowed a program to distinguish one group of people and posts from another.

If they really had to be separated, and I'm not sure that I agree that they must, I'd have VIEWs for each project. I'd keep one table for person and another for post. I'd do the JOINs in the VIEW.


generally you would have 3 tables. one for people, one for projects, and one for the relation between them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜