Reply
Field naming problem?
Old 03-25-2008, 07:30 PM Field naming problem?
KkillgasmM's Avatar
Ultra Talker

Posts: 312
Name: El Phantasmo
Location: England, north west
It seems to me [from what Ive learnt in uni] that its best to keep field names consistent throughout tables, to make things more organised and to make relationships between different tables more obvious.

Ive pasted my plans for [some of] the tables I will be using in my database. The primary key in tblUser will be 'userId'. This will also be contained in tblNews, to show which user posted the news; so I kept them the same to improve the consistency.

But when it came to designing a table to record messages sent between users I ran into a problem. I need 'userId' to be in there, but twice. Once for the user that sent it, and once for the user who is the recipient.

Ive made the fields bold so you know which ones I mean. calling them userIdFrom and userIdTo was the only solution I could come up with.

Is this the best way of naming the fields in a table like this or is there a better alternative?

Code:
tblUser
------------
userId
userUsername
userPassword
userEmail
userLevel

tblNews
------------
newsId
newsDate
newsEntry
userId

tblMessage
------------
messageId
messageDate
messageSubject
messageEntry
userIdFrom
userIdTo
__________________
http://www.inspindesign.co.uk
KkillgasmM is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 03-25-2008, 09:02 PM Re: Field naming problem?
joder's Avatar
Flipotron

Posts: 6,117
Name: James
Location: In the ocean.
Joe Celko has written a lot of books and articles on databases including one book that contains naming information, Joe Celko's SQL Programming style. Here is one article I found on the subject.

http://www.intelligententerprise.com...questid=283968
joder is offline
Reply With Quote
View Public Profile
 
Old 03-25-2008, 09:04 PM Re: Field naming problem?
KkillgasmM's Avatar
Ultra Talker

Posts: 312
Name: El Phantasmo
Location: England, north west
Ahhhh thanks again! Ill check it out.
__________________
http://www.inspindesign.co.uk
KkillgasmM is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Field naming problem?
 

Thread Tools

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 Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12099 seconds with 13 queries