Unix Technical Forum

Normalization / Foreign Key Question

This is a discussion on Normalization / Foreign Key Question within the MySQL General forum forums, part of the MySQL category; --> Hello, A bit embarrassed, I have been away from the databasing side of system development for quite a while ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-18-2008, 09:47 AM
Ben A. Hilleli
 
Posts: n/a
Default Normalization / Foreign Key Question

Hello,



A bit embarrassed, I have been away from the databasing side of system
development for quite a while so am a little rusty. This seems like a simple
issue.



I have a USER table:



userID

fName

lName

address

address2

city

province

country

referrerID



userID is the unique primary key.



My question pertains to referrerID. The referrerID specifies which OTHER
USER referred this new user. Thus it is a foreign key that links to a userID
in another user record. I do not recall ever linking attributes from the
same table (even for different records) so I have a hunch that the way to do
this properly is either:



(A)



User UserReferrer

--------- -------------------

userID (the new userID)-------userID

referrerID (the userID of
the referrer)



or (B)

just store referrerID as a number and use a simple query to get the info for
the referrer when it is required.



Select name from USER

Where userID=currentUsersID





Which is the correct way of doing this? If both, which would be ideal, this
will be a relatively large database with approx 250,000+ users, not all will
have referrerIDs, I would wager maybe 1-10% of these people will have been
referred. Priorities for us are simplicity/scalability, efficiency (in that
order)



Ben A. Hilleli

Programmer / Analyst






Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:20 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com