实体关系图 - 可以有多种类型的实体 [英] Entity Relationship Diagram - Entity which can have multiple types

查看:115
本文介绍了实体关系图 - 可以有多种类型的实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何表示可以是乙烯基和/或CD和/或磁带的Album实体。我假设那些不能被声明为相册实体的子类型,因为没有办法专辑可以是所有这些。它应该是相册实体的多值属性吗?
每种类型的乙烯基,cd,磁带都有不同的属性(例如,乙烯基可能有颜色,cd可能有相关的视频剪辑等)。

How can I represent an Album entity which can be vinyl and/or cd and/or tape. I assume those can't be declared as subtypes of the Album entity as there would be no way the album could be all of them. Should it be a multivalue attribute of the Album entity? Also each type vinyl, cd, tape have different attributes (eg. vinyl might have colour, cd might have an associated video clip etc.)

一个艺术家实体,我可以做个独奏艺术家和一个团体艺术家?我有一个艺术家实体,具有独奏的子类型(具有更多属性)和组(具有艺术家的多值属性)。

And for an Artist entity how could I make a solo artist and a group artist? At the minute I have an Artist entity with subtypes of Solo (with more attributes) and Group (with a multivalue attribute of artists.)

我已经把Solo和Group(MemberOf),这是单独的许多组。

I have put a relationship between Solo and Group (MemberOf) which is 1 Solo to Many Groups.

这是正确的还是应该使其不同?

Is this correct or should I make it different?

谢谢

推荐答案

我可能会从这样开始,然后根据其他需求进行调整:

I would probably start with something like this and then adapt it based on other needs:

albums
    id              unsigned int(P)
    name            varchar(100)
    artist_id       unsigned int(F artists.id)
    released        date
    ...

+----+------------------+-----------+------------+-----+
| id | name             | artist_id | released   | ... |
+----+------------------+-----------+------------+-----+
|  1 | ...But Seriously |         1 | 1989-11-07 | ... |
|  2 | Invisible Touch  |         2 | 1986-06-09 | ... |
|  3 | Heaven and Hell  |         3 | 1980-04-25 | ... |
| .. | ................ | ......... | .......... | ... |
+----+------------------+-----------+------------+-----+

artists
    id              unsigned int(P)
    name            varchar(50)
    ...

+----+------------------+
| id | name             |
|  1 | Phil Collins     |
|  2 | Genesis          |
|  3 | Black Sabbath    |
|  4 | Ronnie James Dio |
|  5 | Dio              |
|  6 | Mike Rutherford  |
| .. | ................ |
+----+------------------+

artists_artists
    id              unsigned int(P)
    artist_id       unsigned int(F artists.id)
    group_id        unsigned int(F artists.id)

+----+-----------+----------+
| id | artist_id | group_id |
+----+-----------+----------+
|  1 |         1 |        2 |
|  2 |         4 |        3 |
|  3 |         4 |        5 |
|  4 |         6 |        2 |
| .. | ......... | ........ |
+----+-----------+----------+

cds
    id                  unsigned int(P)
    album_id            unsigned int(F albums.id)
    ...

+----+----------+-----+
| id | album_id | ... |
+----+----------+-----+
|  1 |        1 | ... |
|  2 |        2 | ... |
| .. | ........ | ... |
+----+----------+-----+

colours
    id                  unsigned int(P)
    name                varchar(20)

+----+------+
| id | name |
+----+------+
|  1 | Red  |
|  2 | Blue |
| .. | .... |
+----+------+

tapes
    id                  unsigned int(P)
    album_id            unsigned int(F albums.id)
    ...

+----+----------+-----+
| id | album_id | ... |
+----+----------+-----+
|  1 |        1 | ... |
|  2 |        2 | ... |
| .. | ........ | ... |
+----+----------+-----+

vinyls
    id              unsigned int(P)
    album_id        unsigned int(F albums.id)
    colour_id       unsigned int(F colours.id)
    ...

+----+----------+-----------+-----+
| id | album_id | colour_id | ... |
+----+----------+-----------+-----+
|  1 |        1 |         1 | ... |
|  2 |        1 |         2 | ... |
|  3 |        3 |         3 | ... |
| .. | ........ | ......... | ... |
+----+----------+-----------+-----+

这篇关于实体关系图 - 可以有多种类型的实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆