![]() |
|
|
|
Registered
|
SQL Server experts - I need your help!!
I have a database I am trying to make sense of. It has about 100 tables (all named in German) and each of those tables has plenty of fields (all named in German).
I need to figure out the relationships between all the fields/tables (assume the related fields share the same name among the tables). Is there a piece of software out there that would analyze the field names and put together the relationships for me, ideally presenting them in a graphical format? I could do it manually, but that would take a week. - Scott |
||
![]() |
|
Registered
|
Pretty sure Microsoft Visio will do it. If I recall, it doesn't "organize" the drawing well, and it might come out looking like spaghetti.
__________________
Silver '88 RoW Carrera Grey '06 A4 Avant Last edited by TheMentat; 03-28-2008 at 09:27 AM.. |
||
![]() |
|
Registered
|
Quote:
I should also mention, that I don't think it will establish relationships between fields unless there is an explicit foreign key relationship.
__________________
Silver '88 RoW Carrera Grey '06 A4 Avant |
||
![]() |
|
Registered
Join Date: Mar 2003
Posts: 10,346
|
The tools from SQL 2k allow a visual representation (think it is in the enterprise manager thingie) , but its been forever since I've used MSSQL...
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.” |
||
![]() |
|
Registered
|
I should emphasize that these tables were imported into SQL Server from a text file or something, so there are no existing relationships that I'm aware of -- these are just raw tables. What I'm trying to do is determine the relationships, not just display them.
Thanks again. |
||
![]() |
|
The Unsettler
|
Quote:
If there are no existing relationships in the text file then there is nothing out there that is going to automagically figure it out.
__________________
"I want my two dollars" "Goodbye and thanks for the fish" "Proud Member and Supporter of the YWL" "Brandon Won" |
||
![]() |
|
![]() |
Registered
Join Date: Jun 2001
Location: St. Louis Missouri
Posts: 1,454
|
To me, the German would suggest it's an SAP database. You might be able to find an SAP reference that would help you make sense of the table & field names.
|
||
![]() |
|
Registered
|
Quote:
I can't think of anything off the shelf. But if I were to do it manually, I'd do it by running queries on the system tables for the DB. Find out which fieldnames occur more than once in the DB, and then find out which tables they occur in.
__________________
Silver '88 RoW Carrera Grey '06 A4 Avant |
||
![]() |
|
Cars & Coffee Killer
Join Date: Sep 2004
Location: State of Failure
Posts: 32,246
|
DBA wanna-be here.
I'd think you'd have to know the data model to automate that kind of thing. If it were even possible to do what you are asking, all of the keys would have to be named the same in each table they are used. One deviation could throw everything off. I don't know of any tool that you can feed a database and it will generate a data model. We use the Rational suite around here to do the opposite (use the data model to generate the database).
__________________
Some Porsches long ago...then a wankle... 5 liters of VVT fury now -Chris "There is freedom in risk, just as there is oppression in security." |
||
![]() |
|
Registered
|
Try this:
select c.name as ColumnName , o.name as TableName , count(cc.name) as NumCols from sysobjects o join syscolumns c on c.id = o.id and o.xtype = 'U' left join syscolumns cc on c.name = cc.name join sysobjects co on cc.id = co.id and co.xtype = 'U' group by c.name, o.name order by NumCols desc, ColumnName, TableName ignore all of the columns that have NumCols = 1
__________________
Silver '88 RoW Carrera Grey '06 A4 Avant |
||
![]() |
|
Registered
|
Quote:
I would second this... the code I provided will hopefully get you started on establishing relationships between the tables based on the column names only. I should also say, that I'm not in any way a DB professional either... so my advice is probably only worth what it cost you! ![]()
__________________
Silver '88 RoW Carrera Grey '06 A4 Avant |
||
![]() |
|
Registered
|
Thanks guys. Mentat, that helped some!
|
||
![]() |
|
Cars & Coffee Killer
Join Date: Sep 2004
Location: State of Failure
Posts: 32,246
|
Mentat, it looks like you are using the LUW version of DB2 based on the column names you selected from the catalog.
__________________
Some Porsches long ago...then a wankle... 5 liters of VVT fury now -Chris "There is freedom in risk, just as there is oppression in security." |
||
![]() |
|
Registered
|
Quote:
you've already lost me!
__________________
Silver '88 RoW Carrera Grey '06 A4 Avant |
||
![]() |
|
Semper drive!
|
All of you are looking at this from the wrong angle. The correct response is...
![]() Just my own $.02. ![]() Randy
__________________
84 944 - Alpine White 86 Carrera Targa - Guards Red - My Pelican Gallery - (Gone, but never forgotten ![]() One Marine's View Igitur qui desiderat pacem, praeparet bellum |
||
![]() |
|