如何规范表?

时间:2011-09-07 19:04:50

标签: mysql

有人能告诉我规范化这张桌子的最简单方法吗?我无法弄清楚如何分组关系。

Film#   Title        Dir#   DirectorName    Actor#  ActorName       Role          Timeon
F1100   Happy Day    D101   Jim Alan    A1000   Judy Foster     Amy Jones     50
                                A1001   Robert Dinero   Harry             30
                                A1004   Harrison Ford   Jack Actress      55
                                A1009   Eddy Murphy Excel Fuse    65
                                A1000   Judy Foster Amy Jones     15
F1101   AirForceOne  D105   Woody Ellen A1000   Judy Foster Amy Jones     50
                                A1004   Harrison Ford   Bill Ford     55
                                A1009   Eddy Murphy Police one    35
                                A1002   Mary Jackson    Police two    45
F1102   RunAwayBride D101   Jim Alan    A1003   Julia Roberts   Amy Jones     50
                                A1007   David Lynch Sam Strickland    45
                                A1004   Harrison Ford   Robber            35
                                A1005   John Wayne  Cab Driver    25
                                A1000   Judy Foster News Reporter     65

1 个答案:

答案 0 :(得分:3)

您需要两个数据表,Film和Person,以及两个交集表,FilmDirector和FilmRole。一个简短的例子:

Film
filmID  title
1100    Happy Day
1101    Airforce One
1102    Runaway Bride


Person
personID    name
101     Jim Alan
105     Woody Ellen
1000    Judy Foster
1001    Robert Dinero
1002    Mary Jackson
1003    Julia Roberts
1004    Harrison Ford
1005    John Wayne
1007    David Lynch
1009    Eddy Murphy


FilmDirector
filmDirectorID  filmID  personID
1               1100    101
2               1101    105
3               1102    101


FilmRole
filmRoleID  FilmID  personID    role            timeOn
1           1100    1000        Amy Jones       50
2           1100    1001        Harry           30
3           1100    1004        Jack Actress    55
6           1101    1000        Amy Jones       50
7           1101    1004        Bill Ford       55
...