Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 song, artist and linker table id's

Author  Topic 

insanepaul
Posting Yak Master

178 Posts

Posted - 2011-12-06 : 06:20:46
The song table has songs written by many artists and the artists have written many songs so I'm using a linker table between them.

Songs have their own id's eg 235a67y543 and so do artists in a similar format.

My first question is if these id's were GUIDS or id's without letters then I wouldn't need to setup an identity seed.

Second question is if I did setup an identity seed for these tables would I use the identity seed in the linker table or the guid's and Id's of the songs and artists.

My feeling is that I should use Identity seeds but can't think why - is it for performance, readability?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-06 : 06:46:06
you will set up fields as identity in parent tables (song,artist) whereas in linker table they will not be identity. you will just make them not nullable type

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

insanepaul
Posting Yak Master

178 Posts

Posted - 2011-12-06 : 07:04:24

Thanks for the reply which answers the parent tables.

Can I just say that in the linker table I wouldn't be using identy seed. I would normally use the Id's from the parent tables but because both tables have unique guids and id's, the linker table could be qwer-1234-qwer, 123456 instead of 1,1

eg linker table I would normally think consists of

SongId ArtistId
1 1
1 2
2 1
3 1


but because song and artist have their own uniques I could use this:

SongId ArtistId
qwert-12345... 24356732
rtyi-234-rt... 24356732
quote:
Originally posted by visakh16

you will set up fields as identity in parent tables (song,artist) whereas in linker table they will not be identity. you will just make them not nullable type

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-06 : 07:10:36
you can use any one of approaches. If you want, you can even add a new identity column in linker table and make it primary key instead of composite keys

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -