I am currently trying to design a social network type of website and this is the class diagram
that I have so far
我目前正在尝试设计一个社交网络类型的网站,这是我到目前为止的类图
at the moment I have userId and username in separate tables because I wanted to normalize these tables but now I am not sure why do I need the userId attribute? I have done research and a lot of similar projects have this attribute but I don't get why? if the username is already going to uniquely identify a particular user.
目前,我在不同的表中有用户id和用户名,因为我想规范化这些表,但现在我不知道为什么我需要userId属性?我做过研究,很多类似的项目都有这个属性,但我不明白为什么?如果用户名已经唯一地标识一个特定的用户。
By the way I am aware I have a problem with the requests table because at the moment with the attributes given I cannot identify a primary key Thanks
顺便说一下,我知道请求表有一个问题,因为在给定属性的时候,我不能识别主键,谢谢。
1 个解决方案
#1
3
Two big reasons I can think of:
我能想到的两个主要原因是:
- Optimization. SQL databases typically perform far better when using integer primary keys than varchar ones. Lookup-something-by-user is one of the most common operations in this environment, so this has real performance implications. Many DBAs don't like GUID/UUIDs as PKs for exactly this reason.
- 优化。在使用整数主键时,SQL数据库通常比varchar主键执行得更好。在这个环境中,查找- someuser是最常见的操作之一,因此它具有实际的性能影响。许多dba不喜欢GUID/ uuid作为PKs,正是因为这个原因。
- Nothing dictates that a username must uniquely identify users. Case in point: Stack Exchange user handles don't have to be unique, and are freely editable.
- 没有什么规定用户名必须唯一地标识用户。恰当的例子:栈交换用户句柄不必是唯一的,并且是可*编辑的。
#1
3
Two big reasons I can think of:
我能想到的两个主要原因是:
- Optimization. SQL databases typically perform far better when using integer primary keys than varchar ones. Lookup-something-by-user is one of the most common operations in this environment, so this has real performance implications. Many DBAs don't like GUID/UUIDs as PKs for exactly this reason.
- 优化。在使用整数主键时,SQL数据库通常比varchar主键执行得更好。在这个环境中,查找- someuser是最常见的操作之一,因此它具有实际的性能影响。许多dba不喜欢GUID/ uuid作为PKs,正是因为这个原因。
- Nothing dictates that a username must uniquely identify users. Case in point: Stack Exchange user handles don't have to be unique, and are freely editable.
- 没有什么规定用户名必须唯一地标识用户。恰当的例子:栈交换用户句柄不必是唯一的,并且是可*编辑的。