简体   繁体   English

MDS 中的关系

[英]Relationships in MDS

I have a question, with regards to how do you create the relationships between members of two different entities?我有一个问题,关于您如何在两个不同实体的成员之间创建关系? For example, in case of 1:1 you can create a domain-based attribute that is referencing the entity.例如,在 1:1 的情况下,您可以创建引用实体的基于域的属性。 But in case you have a customer with multiple addresses, and you have an address entity.但是,如果您有一个拥有多个地址的客户,并且您有一个地址实体。

When you update the member of the Address attribute of the Customer entity, based on the 1:M how would we be able to surface that relationship and connect the Address entity to the Customer entity?当您更新 Customer 实体的 Address 属性的成员时,基于 1:M,我们如何能够显示该关系并将 Address 实体连接到 Customer 实体?

So in case an Address member in the Customer entity changes, how would that update process work since we don't have a mapped relationship?因此,如果 Customer 实体中的 Address 成员发生更改,那么由于我们没有映射关系,该更新过程将如何工作?

I know in M:M you would use a bridge table.我知道在 M:M 中你会使用桥接表。 And in the MDS database which table would contain that relationship info?在 MDS 数据库中哪个表将包含该关系信息?

Any suggestions to articles and blog posts/Videos or ideas, would be greatly appreciated.对文章和博客文章/视频或想法的任何建议,将不胜感激。

Thanks, Andrea谢谢,安德里亚

In MDS (Master Data Services), you can use the Hierarchy feature. 在MDS(主数据服务)中,您可以使用层次结构功能。

- Option 1: create Explicit Hierarchy -选项1:创建明确的层次结构

If you're using SQL Server 2012 (possibly 2014 too), then an Explicit Hierarchy will solve this. 如果您使用的是SQL Server 2012(也可能是2014),则显式层次结构将解决此问题。 (see: Explicit Hierarchies (Master Data Services) ) (请参阅: 显式层次结构(主数据服务)

Basically, you will be able to use Customer entity rows as parent nodes in the hierarchy (think of a tree structure) and assign one or more Address entity rows as child of each Customer. 基本上,您将能够使用“客户”实体行作为层次结构中的父节点(以树结构为例),并将一个或多个“地址”实体行分配为每个“客户”的子级。

As the name suggests, this needs to be "explicitly" managed.. means either someone will do this manually (drag-drop) using the MDS Hierarchy UI page or you can use an SSIS package to automate it while loading the staging table. 顾名思义,这需要“显式”管理..意味着有人可以使用MDS层次结构UI页面手动(拖放)此操作,也可以在加载登台表时使用SSIS包使其自动化。 (see: Move Explicit Hierarchy Members by Using the Staging Process (Master Data Services) ) (请参阅: 使用暂存过程移动显式层次结构成员(主数据服务)

NOTE: Explicit Hierarchies have been Deprecated (starting SQL 2016 ...I think) 注意:不建议使用明确的层次结构(我认为是从SQL 2016开始...)

- Option 2: create Derived Hierarchy (bridge table- M:M) -选项2:创建派生层次结构(桥表-M:M)

This is similar to the bridge table concept that has been suggested earlier for M:M relationship, but in the MDS context. 这与之前针对M:M关系建议的桥接表概念类似,但是在MDS上下文中。

  1. Create another entity, call it CustomerAddressRelationship (let's say), let's call it CAR for now. 创建另一个实体,将其命名为CustomerAddressRelationship (假设),现在将其称为CAR。

  2. Add 2 Domain Attributes to CAR: one referring to the Customer entity, the other to the Address entity. 向CAR添加2个域属性:一个指向客户实体,另一个指向地址实体。

  3. Now, if you want, you can create a Derived Hierarchy on this CAR entity in the format CAR > Customer > Address . 现在,如果需要,您可以在该CAR实体上以CAR > Customer > Address的格式创建派生层次。 Read more about Derived Hierarchies: Many-to-Many (M2M) Relationships 阅读有关衍生层次结构的更多信息:多对多(M2M)关系

- Option 3: create Derived Hierarchy (1:M) -选项3:创建派生层次结构(1:M)

  1. Don't create CAR. 不要创建CAR。 Just add a column CustomerID (let's say) to the Address entity. 只需在Address实体中添加一列CustomerID (例如)。 This way every Address may have 0 or 1 Customer related to it. 这样,每个地址可能都有0或1个与之相关的客户。

  2. Create a Derived Hierarchy for 1:M Relationship 为1:M关系创建派生层次

Hope this helps. 希望这可以帮助。

A one to many relationship consists of 2 tables, the many table referencing the one table. 一对多关系由2个表组成,多表引用一个表。

Customer Table                                              Address Table
+-------------+------------+-----------+----------------+   +------------+-------------+---------+
| customer_id | name_first | name_last | customer_class |   | address_id | customer_id | address |
+-------------+------------+-----------+----------------+   +------------+-------------+---------+
|           1 | Barack     | Obama     |              2 |   |          1 |           1 | Place1  |
|           2 | George     | Bush      |              2 |   |          2 |           1 | Place2  |
|           3 | Michael    | Jordan    |              1 |   |          3 |           2 | Place3  |
+-------------+------------+-----------+----------------+   |          4 |           3 | Place4  |
                                                            |          5 |           3 | Place5  |
                                                            |          6 |           3 | Place6  |
                                                            +------------+-------------+---------+

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

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