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
 Database Design and Application Architecture
 Primary and Foreign Keys

Author  Topic 

DJBruteForce
Starting Member

1 Post

Posted - 2008-12-10 : 01:18:31
Hi there

I have 3 DB tables; Member, Visitor and Downloads. Both members and visitors can have many downloads but if a visitor does a download and is not a member, there will not be a link between the member > download table. How would I design the primary and foreign keys for this scenario? Here an example of the structure I have.

Member
-MemberID
-MemberName

Visitor
-VisitorID
-VisitorIP

Downloads
-DownloadID
-MemberID
-VisitorID

Thanx,
DJ

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-12-10 : 10:27:18
quote:
Originally posted by DJBruteForce

Hi there

I have 3 DB tables; Member, Visitor and Downloads. Both members and visitors can have many downloads but if a visitor does a download and is not a member, there will not be a link between the member > download table. How would I design the primary and foreign keys for this scenario? Here an example of the structure I have.

Member
-MemberID PK
-MemberName

Visitor
-VisitorID PK
-VisitorIP

Downloads
-DownloadID PK
-MemberID FK
-VisitorID FK
Thanx,
DJ

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-10 : 11:13:59
Also it would be better to make PKs as identity columns
Go to Top of Page
   

- Advertisement -