数据库设计重复列-websafe urls
为了良好的关系数据库设计:
数据库中当前有两列:“GroupName”和“WebGroupName”。第二列用于对配置文件进行简单的 URL 访问。例如:www.example.com/myWebGroupName 这样做的原因是它避免在 url 中传递空格,例如:www.example.com/my Web Group Name 不起作用
重新迭代数据库结构;第一列将存储“我的组名称”,第二列将存储“MyGroupName”。
可能的解决方案可能会错误地存储不带空格的组名称,然后使用某些正则表达式将空格添加回来。 我的问题的焦点是如何消除对存储接近重复日期的两列的需要。
谢谢您的宝贵时间
In the interest of good relational database design:
There are currently two columns in the DB: "GroupName" and "WebGroupName". The second column is used for simple url access to a profile. Eg: www.example.com/myWebGroupName the reason for this is that it avoids spaces being passed in the url for example: www.example.com/my Web Group Name would not work
To re-iterate the DB structure; column 1 would store "My Group Name" and column two would store "MyGroupName".
Possible solutions may err on the side of storing the group name without spaces then using some regular expression to add the spaces back. The focus of my question is how to eliminate the need for two columns storing near-duplicate date.
Thank you for your time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设 URL 中的空格确实存在问题(正如 Larry Lustig 指出的那样,这不一定是问题)——那么拥有两列通常包含非常相似信息的关系数据库设计并不是很糟糕。
要避免(规范化)的重复类型涉及跨多行的重复。如果您有两列旨在包含不同但相关的信息,那么这两列完全没问题,并且您没有违反任何规则。有时这两列相等(巧合)这一事实并不是问题。
你说:
由此我假设对您的系统最重要的是网络组名称。如果组名是驱动程序,那么编写一个删除空格的表达式将是微不足道的。如果网络组名称是可以根据组名称任意设置的名称,那么您应该用空格存储名称,并在需要网络组名称时将其替换为空字符串。如果网络组名称不是完全任意的,那么您确实有两个独立的数据点,并且它们需要存储在两个单独的列中。
Assuming that you really have a problem with spaces in URLs (as Larry Lustig pointed out it isn't necessarily a problem) - Then it isn't bad relational database design to have two columns that often have very similiar information.
The kind of repetition that is to be avoided (normalized) deals with repetition across multiple rows. If you have two columns which are meant to contain different, but related information, then these two columns are perfectly OK and you aren't breaking any rules. The fact that sometimes these two columns are equal (coincidentally) is not a problem.
You said:
From this I assume that what is most important to your system is the web group name. If the group name were the driver then writing an expression that removes spaces would be trivial. If the web group name is something that can be set arbitrarily based on the group name, then you should store the name with spaces and replace them with empty strings when you need a web group name. If the web group name is not completely arbitrary then you really do have two independent data points and they need to be stored in two separate columns.