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 > newbie to database design

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-14-09, 14:42
lloowen lloowen is offline
Registered User
 
Join Date: Sep 2009
Posts: 4
newbie to database design

Hello all!

How does one design a table that will for example store information about members. These members can only be a member of one club or another club, but not both.
How does one implement such a control into a table.

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 09-14-09, 17:37
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
CREATE TABLE clubs
( club_id INTEGER NOT NULL PRIMARY KEY
, club_name VARCHAR(255)
);
CREATE TABLE members
( member_id INTEGER NOT NULL PRIMARY KEY
, club_id INTEGER NULL
, CONSTRAINT member_club_fk FOREIGN KEY ( club_id ) REFERENCES clubs (club_id)
, member_name VARCHAR(127)
);
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 09-14-09, 17:39
dportas dportas is offline
Registered User
 
Join Date: Dec 2007
Location: London, UK
Posts: 732
By giving the table a key (uniqueness constraint). If you are serious about learning then I suggest you read a decent introduction and study some basic principles rather than jump straight into design problems. If you have a particular example in mind then post that example.
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