Database Design Primay Key, ID vs String
Posted
by LnDCobra
on Stack Overflow
See other posts from Stack Overflow
or by LnDCobra
Published on 2010-03-31T09:33:03Z
Indexed on
2010/03/31
9:43 UTC
Read the original article
Hit count: 417
Hi, I am currently planning to develop a music streaming application. And i am wondering what would be better as a primary key in my tables on the server. An ID int or a Unique String.
Methods 1:
Songs Table: SongID(int), Title(string), Artist*(string), Length(int), Album*(string)
Genre Table Genre(string), Name(string)
SongGenre: SongID*(int), Genre*(string)
Method 2
Songs Table: SongID(int), Title(string), ArtistID*(int), Length(int), AlbumID*(int)
Genre Table GenreID(int), Name(string)
SongGenre: SongID*(int), GenreID*(int)
Key: Bold = Primary Key, Field* = Foreign Key
I'm currently designing using method 2 as I believe it will speed up lookup performance and use less space as an int takes a lot less space then a string.
Is there any reason this isn't a good idea? Is there anything I should be aware of?
© Stack Overflow or respective owner