Link to home
Start Free TrialLog in
Avatar of aahmed19
aahmed19

asked on

Extract Relationship from MS SQL Server

Hi Exprets,

I am making an application using MS SQL Server and I need to know that what kind of relationships are existing between table e.g. 1-1 or 1-M. I can get the constraint's, coulumn, table, types information from INFORMATION_SCHEMA at this point but I still need to find the relationship types between tables.
I am using C# and ADO.NET and the version of Database Server right now is MS SQL Server 2000 but Finally I will be utilizing MS SQL Server 2005.

Any idea, suggestion, snippet?

Thankx
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

It is not possible to determine if a relationship is 1-1 or 1-M by simply examining the constraints on the tables.  You need to understand the data model, and that is something that is not obvious from the relationships alone.

1-1 and 1-M can show precisely the same constraints.  

AW

Avatar of snow_moon
snow_moon

If you have Enterprise Manager, you may create Database Diagrams to show the relationship between tables. Check the content about Database Diagrams in MS SQL-Server Book Online.
--"The endpoints of the line indicate whether the relationship is one-to-one or one-to-many.  If a relationship has a key at one endpoint and a figure-eight at the other, it is a one-to-many relationship. If a relationship has a key at each endpoint, it is a one-to-one relationship."
ASKER CERTIFIED SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial