开发者

Is the design on 3rd normal form?

I have a tab开发者_如何学Pythonle that has an attribute category. E.g a table where I save songs which has an attribute Genre:

Songs(
ID (INT), 
Name (STRING), 
Genre: (STRING)
)

Is the table in 3rd normal form?

I mean I know it is better to save the Genrein another table and the have a relationship between tables like:

Songs(
ID (INT), 
Name (STRING), 
Genre_ID: (INT)
)

Genre(
ID (INT),
Name (String)
)

where Songs.Genre_ID = Genre.ID.

But I can not determine if the first case (with one table) does violate any rule of 3rd normal form!

Does it? If yes, which one?

Thanks, Mike


Repeat after me.

"ID numbers have nothing to do with normalization. ID numbers have nothing to do with normalization. ID numbers have nothing to do with normalization."

If your goal is to store one genre per song name, then this table

song_name           genre
--
Toxic               Pop
Itsy Bitsy Spider   Children's

where song_name is the primary key, is in 5NF. (And 4NF, and 3NF, and so on).


What are the keys? What dependencies is the table supposed to satisfy? Those are the things we need to know to answer your question.

My guess is that ID is the only key and that ID->{Name,Genre} and that there are no other non-trivial, non-key dependencies. If that's correct then Songs is in 3NF. More importantly it is in BCNF and 5NF.

Replacing the string attribute Genre with an integer Genre_ID has absolutely nothing to do with any normal form.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜