内部管理员聊天系统的数据库设计
我正在尝试实现一个内部聊天系统供我们的管理员使用,但我对数据库设计不太确定。到目前为止,我已经有了这个(如下),但希望得到验证和/或改进建议。
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)
}
所以,这就是我到目前为止所拥有的,但我不确定它是否“足够”。将与数据库交互的应用程序是使用 ASP.NET MVC 2 和 Linq to SQL 构建的。
预先感谢您的任何建议!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ChatEmployees 表似乎有点多余。除非你需要记录某人正在聊天但从未说过任何话,否则我会放弃它。
回复:Message.text
我认为“text”可能是一个保留字,因为它在 SQL 中用作数据类型。可能想避免使用这个名字。
另外,varchar 512 似乎是允许消息使用任意数量的字符,为什么是奇数?您选择它只是因为出于某种原因它是 2 的幂吗?
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?