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
|