Thanks for this.
I think currently we're using Entity Framework with that second pattern -- there would be a Person table, a Customer table, and an Employee table, and a constraint that Employee.Id and Customer.Id are both foreign keys to Person.Id. -- a 1-to-0..1 cardinality. That's enforced by a foreign key constraint.
I'm not sure how I ensure this kind of referential integrity in an anchor model, though. I see how to do 1-to-1, 1-to-M, M-to-M, but I'm not sure how to specify 1-to-0..1. So something like "if there is a record in Customer, there is a record in Person, but not vice-versa (because it might be an Employee)". Is there something I can do (inside the raw XML, if not the online modeler) to specify this?
--
In a related note, if you have two anchors and a 1-M tie, it's possible to imagine a pseudo-foreign-key column in the 'many' l-view. This is what you'd tend to see in a classic 3NF design.
As an example, take the Order-Order item model, the classic one-to-many structure;
http://www.anchormodeling.com/modeler/latest/?id=ahNzfmFuY2hvcm1vZGVsZXItaHJkcg0LEgVNb2RlbBiS4U0M
In 3NF we'd expect to see tables
Order { OR_ID (PK) }
Item { IT_ID (PK), OR_ID (FK) }
And thus in Anchor Modeling, I might expect them in the l-views;
lOR_Order { OR_ID (PK) }
lIT_Item { IT_ID (PK), OR_ID (FK) }
And I think it'd be possible to extend the views pretty simply, in theory;
CREATE VIEW [dbo].[lIT_Item] WITH SCHEMABINDING AS
SELECT
[IT].IT_ID,
[tie].OR_ID_Order -- pseudo-foreign-key
FROM
[dbo].[IT_Item] [IT]
left join [lOR_Order_IT_Items] tie on tie.[IT_ID_Items] = [IT].IT_ID;
I raise this because I'm trying to adapt Anchor Modeling to Entity Framework, and EF is going to expect to use standard foreign key columns for 1-M relationships. So it's going to try things like;
SELECT ...
FROM ITEM innder join ORDER on ITEM.OR_ID = ORDER.OR_ID
and corresponding inserts, updates, and deletes.
Has this approach been considered?
Thanks.