I have the following tables in the database (just a demo, of course):
Positions
PositionId
Limits
LimitId PositionId
I want to left join them into a single entity (always have position, not always have a limit attached to it):
Position
PositionId LimitId
I've seen articles regarding one-to-one mapping and "Table per type inheritence", and tried to implement the same method here, but with no sucess. Is that even possible?
-
I think what you want is an ordinary inner join where your foreign key (PositionID in the Limits table) is allowed to be null.
Robert Harvey : I can see that happening in a report, where you have grouping capabilities. Is this your intent? It's still an ordinary join, unless you don't want to see the row at all when there are no associated limits records. Then you do need a left-join, checking for Limits.PositionID Not Null.From Robert Harvey -
Nir,
Does this article contain what you are looking for?
From Robert Harvey -
Yes and no...In my scenario, the 2nd option is the applicable one, since I don't have the same primary key in both tables. so, I must create an updateable view...The problem with updateable view is that I can't modify fields which are in different tables and expect the database to handle it, unless I use "Instead of" triggers, which I really don't want to get into at all... So, I guess there's nothing out of the box for me...damn. (Unless you have another idea...)
Anyways, I really thank you for your help, it's much appreciated. Nir.
From nirpi
0 comments:
Post a Comment