以第五范式表示三路数据库函数依赖

发布于 2024-07-18 08:57:15 字数 384 浏览 3 评论 0原文

是否可以用第五范式表示非键列的复合键函数依赖?

我有三个表,

users
----------
id
name

events
----------
id
name

events_users
---------------------------
id
user_id
event_id
participation_type (ENUM)

据我所知,第五范式需要将表以自己的小实体表示。 所以我猜events_users表中的participation_type不能被称为第五范式?

谁能建议我一个更好的解决方案?

问题是,我一直在使用CodeIgniter的DataMapper库,其中每个表需要独立存在,即第五范式。

Is it possible to represent a composite key functional dependency of a non key column in fifth normal form?

I have three tables,

users
----------
id
name

events
----------
id
name

events_users
---------------------------
id
user_id
event_id
participation_type (ENUM)

As I know, the 5th normal form needs the tables to be represented in its own small entity. So i guess the participation_type in events_users table cannot be called a 5th normal form?

Can anyone suggest me a better solution?

The problem is, I've been using the DataMapper library of CodeIgniter where each table need to exist independently, ie 5th normal form.

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

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

发布评论

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

评论(1

你好,陌生人 2024-07-25 08:57:15

据我所知,您给出的示例已经是第五范式

表中的列太少了,我看不到任何其他方式来排列它们!

据我所知,“participation_type”不会违反任何 NF 规则,因为没有其他列在语义上与其相关。

编辑回复评论:
也许正如您所建议的,这是 Datamapper/Codeigniter 的其他问题,与 5NF 无关。

如果您无法将字段添加到它生成的 user_events 表中,那么您可能需要抢占它并创建另一个实体,我们将其称为“出勤”(或模型中有意义的任何名称)。 出勤将具有以下字段:

Attendance
----------
id
participation_type (ENUM)

然后告诉 Datamapper 出勤与用户和事件相关,并且它将生成(或要求您生成,或其他)两个链接表:

user_attendance
---------------
id
user_id
attendance_id

event_attendance
----------------
id
event_id
attendance_id

如果您按照这些方式执行某些操作,那么您将拥有一个您可以添加字段的考勤实体。

免责声明:我对 Datamapper 一无所知,我只是在这里阅读字里行间

As far as I can tell, the example you give is already in Fifth Normal Form.

You have so few columns in the tables that I can't see any other way to arrange them!

As far as I can tell, 'participation_type' does not break any NF rules because there are no other columns semantically related to it.

edit in response to comment:
Perhaps as you suggest this is some other problem with Datamapper/Codeigniter that is not related to 5NF.

If you cannot add fields into the user_events table that it generates, then perhaps you need to pre-empt it and create another entity, lets call it 'Attendance' (or whatever makes sense in your model). Attendance will have these fields:

Attendance
----------
id
participation_type (ENUM)

Then tell Datamapper that Attendance is related to both Users and Events, and it will generate (or ask you to generate, or whatever) two linking tables:

user_attendance
---------------
id
user_id
attendance_id

event_attendance
----------------
id
event_id
attendance_id

If you do something along those lines, then you will have an Attendance entity that you can add fields to.

Disclaimer: I dont know anything about Datamapper, I'm just reading between the lines here

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