BrianJ
BrianJ

Reputation: 43

Mailbox schema question

I created the schema for messaging (mixture of chat messages, onsite messages and email functionality) and i noticed all sample schemas have the main table as "mailbox" and link messages to a mailbox. But a mail belongs to a user and anyways each user has only one inbox no matter where, so what is the purpose of this table and linking this way?

If i do it like this: Message table links the user_id as FK to the User table will that work or do i need to link message to a mailbox then link that to a user?

Also is bigint big enough to be the data type for messages? (Note: Message = email + onsite communication like facebook messages + chat messages + comments people leave on profile). So I assume bigint may get overrun soon if there are enough users sitting online day and night sending messages?

Upvotes: 0

Views: 249

Answers (1)

Ken Downs
Ken Downs

Reputation: 4827

The only reason to have the third table is if there will be multiple values in it. Since you say that a user has only one mailbox, then mailbox=user. Your two-table solution will work fine in that case.

On MS SQL Server, bigint can count up to 9,223,372,036,854,775,807. You will be long retired on your yacht if you ever get within 1 millionth of that load.

Good luck!

Upvotes: 1

Related Questions