Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Field naming problem?
Old 03-25-2008, 08:30 PM Field naming problem?
pealo86's Avatar
Super Spam Talker

Posts: 850
Name: Matt Pealing
Location: England, north west
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Old 03-25-2008, 10:02 PM Re: Field naming problem?
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
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, 10:04 PM Re: Field naming problem?
pealo86's Avatar
Super Spam Talker

Posts: 850
Name: Matt Pealing
Location: England, north west
Trades: 0
Ahhhh thanks again! Ill check it out.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Reply     « Reply to Field naming problem?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 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.11862 seconds with 12 queries