views:

20

answers:

1

Hi, I'm trying to implement an internal chat system for our admins to use, but I'm not too sure on the database design. I have this (below) so far, but would appreciate a verification and/or recommendation for improvement.

Employees {
    EmployeeId (smallint)
    // ...
}

Chat {
    ChatId (int)
    Stamp (datetime) // Obsolete, ignore...
}

ChatEmployees {
    ChatEmployeeId (int) // Or bigint?
    ChatId (int) -> Chat.ChatId
    EmployeeId (smallint) -> Employees.EmployeeId
}

Messages {
    MessageId (int) // Or bigint?
    AuthorId (smallint) -> Employees.EmployeeId
    ChatId (int) -> Chat.ChatId
    Text (varchar(512))
    Stamp (datetime)
}

So, that's what I have so far, but I'm not sure if it's "sufficient". The application that will be interacting with the database is built with ASP.NET MVC 2 and Linq to SQL.

Thanks in advance for any suggestions!

+1  A: 

The ChatEmployees table seems kind of redundant. Unless you need to record that someone was in a chat but never said anything I'd drop it.

Re: Message.text
I think "text" might be a reserved word as it is used as a datatype in SQL. Might want to avoid that name.

Also, varchar 512 seems like kind of an arbitrary number of characters to allow for a message, why the odd number? Are you picking it just because it is a power of 2 for some reason?

JohnFx
Now that you mention it, the `ChatEmployees` is redundant and unnecessary. "Text" is actually not a reserved keyword, I have a `Notes` table which uses "Text" as a field and SQL isn't angry about it. As for the field length, I just put 512 as a number so I can write my example, not really sure what would be appropriate...
Alex
Yeah, I did some double checking and you are right about Text not being reserved. However, I'd still advise avoiding it because it could lead to some confusion with the type. Just my personal opinion though and not a hard-fast rule.
JohnFx
You may be right, but I like it because when I'm writing the code for the app, I do a reference like `<%=Note.Text %>` and it just "feels right". But, that's my opinion. :)
Alex