对向表添加字段感到困惑

发布于 2025-01-02 15:20:34 字数 154 浏览 1 评论 0原文

我有这些信息,我必须建立一个数据库:

一个人有姓名、姓氏、婚姻状况、邮件、电话号码、职业、活动领域(不属于公司的人的活动领域 => 他的技能) ,公司名称

我想知道字段:公司名称和活动领域,我应该将它们添加到表 Personne 还是将它们放在另一个表中?

I have those information and I have to build a database:

a Person have name,lastname,marital status, mail,phone number,profession,field of activity(the field of activity of the person not of the company =>his skill),company name

I want to know the fields: company name and field of activity, should I add them to the table Personne or put them in another table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橘虞初梦 2025-01-09 15:20:34

为了灵活性,最好将可重复的数据存储到单独的表中,避免冗余并确保数据一致性。这称为规范化,它可能是关系数据库设计中最基本的原则。因此,是的,将公司技能,以及很可能的职业活动领域存储在单独的表中,使用 外键 来引用这些使用外键的内容。

It is better to store data that can be repeated into separate tables for flexibility, avoiding redundancy and ensuring data consistency. This is called normalization and it is probably the most fundamental principle in relational database design. So, yes, store companies and skills, and most likely also profession and field of activity in separate tables and use foreign keys to refer to these using foreign keys.

无声情话 2025-01-09 15:20:34

取决于您是否拥有超过 1 个组织或每人技能。

假设您有 1 个组织和每人 1 个技能,您将得到类似这样的内容

Table Person
 person_id
 organisation_id
 skill_id
 etc. 

,当然还有相应的组织和技能表。

如果每人有超过 1 个关系,那么您就有 1-n-1 关系:

Table Person
 person_id

Table skill
 skill_id
 text
 etc.

Table skill_person
 skill_id
 person_id

对于组织来说也是如此。有关这些内容的背景,请谷歌 1-n-1 关系、数据库规范化和实体关系图。

Depends if you have more than 1 organisation or skill per person.

Assuming you have 1 organisation and 1 skill per person you'll get something like this

Table Person
 person_id
 organisation_id
 skill_id
 etc. 

And corresponding tables for organisation and skill of course.

If you have more then 1 per person you have 1-n-1 relationship:

Table Person
 person_id

Table skill
 skill_id
 text
 etc.

Table skill_person
 skill_id
 person_id

Same thing for organisations. For background on this stuff google 1-n-1 relationships, database normalisation and entity relationship diagrams.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文