If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Database design SQL 2005

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-28-10, 14:15
bcahill bcahill is offline
Registered User
 
Join Date: Apr 2010
Posts: 3
Database design SQL 2005

I am beginner trying to design a database using SQL Server 2005. I have three tables:

AdminMember
AMem_AdminId (uniqueidentifier, PK)
AMem_UserName
AMem_Password

CompAcct
Comp_CompId (uniqueidentifier, PK)
Comp_Website
Comp_Name

AdminCompActt
AdCA_AdminId
AdCA_CompID

The AdminMember table holds all Admins. The CompAcct table holds all companies.

I'm trying to use the AdminCompAcct table to link the above referenced tables. This way I can keep track of each Admin, each Company, and which Company each Admin belongs to.

The issue I'm running into is how to link them according to best practices. Because both Amem_AdminID and Comp_CompID are uniqueidentifiers and PK, it seems I cannot create both AdCA_AdminID and AdCA_CompId as a FK. The first one works fine but the second one generates an error. (The columns in table 'AdminCompAcct' do not match an existing primary key or UNIQUE constraint).

I understand the error message but what is the best way resolve or design this? Thanks for your help.

Brian
Reply With Quote
  #2 (permalink)  
Old 04-28-10, 15:34
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
There is no reason you could not create that foreign key to CompAcct.Comp_CompId

There is something you are missing. Post the DDL of the tables for us.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #3 (permalink)  
Old 04-28-10, 15:38
bcahill bcahill is offline
Registered User
 
Join Date: Apr 2010
Posts: 3
Got it figured out on another forum. I had to create a composite key for (AdCA_AdminId, AdCA_CompID). I knew nothing about composite keys. Definitely a newbie to all of this.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On