문제

I have a table 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

도움이 되었습니까?

해결책

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.

다른 팁

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top