on 07-29-2016 5:52 PM
With Parent/Child relationships, I'd like all changes to my parent table's id to be propagated to the child table's FK. Mostly, if I create the FK between parent1 and child1 and then later I tag the PK of parent1 as a particular domain, how do I get the child's domain to match?
1) How do I have PD do this by default?
2) How do I ask PD to make sure this happens for any and all FK relationships that exist already?
Check the Model Options for your PDM. In the Reference section, there is an option to migrate domain links to FK columns.
I found I had to disable this option, then re-enable it get domains to migrate. Domains are only migrating when a reference is created, not when I change the domain in the parent column. I also found that propagation of changes to the parent column's data type is more widespread if the data type is changed via a table symbol on a diagram, rather than via the column's property sheet. Any data types that aren't changed should be flagged by a model check, and you can run the auto-correction to fix them.
I hope SAP are monitoring this conversation .
There isn't a built-in mechanism that I can find to migrate domain links from parent to child columns. A script to do this is fairly simple. I created this just now as a Method for Columns. It could also be implemented as a model check.
Sub %Method%(obj)
' Implement your method on <obj> here
if not obj.foreignkey then ' not FK
exit sub
end if
dim FKJoin
for each FKJoin in obj.ForeignKeyJoins
FKJoin.RefreshJoin()
if FKJoin.ParentTableColumn.Domain is nothing then ' parent column has no domain
output "Parent column for " & obj & " has no domain"
exit for
end if
if FKJoin.ParentTableColumn.Domain = obj.Domain then ' same domain
output "Domains match for " & obj
else
set obj.Domain = FKJoin.ParentTableColumn.Domain
output " changed Domian for " & obj & " to match domain on " & FKJoin.ParentTableColumn.DisplayName
end if
next ' FK Join
End Sub
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There was a typo and an omission in the script. This one is better (it removes the domain from the FK column if the parent column has no domain).
Sub %Method%(obj)
' Implement your method on <obj> here
if not obj.foreignkey then ' not FK
exit sub
end if
dim FKJoin
for each FKJoin in obj.ForeignKeyJoins
FKJoin.RefreshJoin()
if FKJoin.ParentTableColumn.Domain is nothing then ' parent column has no domain
output "Parent column for " & obj & " has no domain"
obj.Domain = Nothing
exit for
end if
if FKJoin.ParentTableColumn.Domain = obj.Domain then ' same domain
output "Domains match for " & obj
else
set obj.Domain = FKJoin.ParentTableColumn.Domain
output " changed Domain for " & obj & " to match domain on " & FKJoin.ParentTableColumn.DisplayName
end if
next ' FK Join
End Sub
Now I've slept on it, I think it would be better for the script to process all the reference joins in a model or package, making sure that ChildTableColumn matches ParentTableColumn where required. This script would be a right-click menu item for the model or package, and could also be run as part of a Transformation. A Custom Model Check for columns would also be helpful.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.