简体   繁体   English

关系数据库和网络结构

[英]relational database and net structure

The company Microsoft could be referred as "microsoft", "ms" or "m$" etc. We may say these names are alias to one single identity. 微软公司可以称为“ microsoft”,“ ms”或“ m $”等。我们可以说这些名称是一个单一身份的别名。 If you want to store the "alias" relationship, you might have to do it as the following pairs 如果要存储“别名”关系,则可能需要按照以下对进行操作

microsoft      ms 

ms             microsoft

microsoft      m$

m$             microsoft

ms             m$

m$             ms

Or maybe there's a better approach? 还是有更好的方法?

Sure. 当然。 Don't store a table that shows a bunch of aliases. 不要存储显示别名的表。 Instead have each company given one ID number, and use a secondary table to provide the aliases: 而是给每个公司一个ID号,并使用辅助表来提供别名:

Company table 公司表

CompanyID  PreferredNameID
12345      934

Name table 名称表

CompanyID  NameID  Alias 
12345      934     Microsoft
12345      384     M$
12345      823     MS

This gives you the ability to have as many aliases as needed, and when you make reports on the company you will reference the preferred name. 这样,您便可以根据需要具有多个别名,并且在向公司进行报告时,将引用首选名称。

-Adam -亚当

You can accomplish this with a "TAG" schema. 您可以使用“ TAG”模式来完成此操作。

interest
--------
iPK
value

junction
---------
iPK
aPK

alias
-------
aPK
value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM