April 16, 2007 at 2:05 pm
Hello,
I need to query a table for the its relations (foreign keys). I figured it by using system stored procedure sp_fkeys. I now need to figure out the type of relation (1:1, 1:M, M:1, and M:M). How can I do this?
Thanks
April 16, 2007 at 7:09 pm
the Logical design is not saved anywhere in the database that you can query for.
you have to figure it out by the way its modeled.
if CustomerID is the primary key in one table, and is Referenced by another table (Orders) then it is likely a 1 to many, but you don't know that unless there is an explicit Constraint on the CustomerID in Orders.
if you do not have design documentation, your just going to have to reverse engineer it. I do not know of any other way
April 17, 2007 at 11:35 am
Yeah, especially since M:M is usually done through a third table.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply