April 3, 2012 at 6:51 am
In SSMS designer when you create a relationship from one table to the next it doesn't have a setting to choose 1-to-1 or 1-to-M .
All that appears to happen is that you right click on the table that you want to have the foreign key in and select design. I use the Guid column from the other table in the left column and that's it. It doesn't ask as Access would what's the relationship, why? Does it guess it?
I assume that the table I inserted the foreign key into should be the 'many' and the primary table the 'one'. But I cannot see any confirmation of this. Is there a way to test relationship cardinality in SSMS? I tried right clicking on the SSMS designer on the relationship link but you can't edit and create this.
April 3, 2012 at 6:56 am
to make it 1:1, you simply add a unique constraint on the child table's column that is referencing the Parent;
so it's not a "type" of foreign key you are looking for, but an additional constraint...a Refernece AND can be only one...that jsut requires two constraints.
Lowell
April 3, 2012 at 6:56 am
SQL can figure it out by checking which table has the unique constraint on the column.
If both sides have a unique constraint, then it's a 1:1 foreign key, otherwise it's 1:m where the 1 is the table with the unique constraint on the foreign key column
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 3, 2012 at 7:10 am
So if I haven't a constraint it should be m on the table with the created foreign key.
I guess I wIll just have to get used of it. Not initially as comforting as seeing the relationship though.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply