Solved

Table Structures (Foreign Keys)

Posted on 1999-01-28
7
244 Views
Last Modified: 2010-04-06
Would like to know if there is an easy way to look at a tables structure and identify which fields are setup as foreign keys.  User Delphi with SQL.  Any assistance would be greatly appreciated
0
Comment
Question by:GGriffith
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1363714
Hi GGriffith,

what SQL-ServerSystem (Oracle, Interbase ...)?

meikl
0
 
LVL 5

Expert Comment

by:heathprovost
ID: 1363715
you might be able to do something like this:

with TableOrQuery do
  for I := 0 to FieldCount - 1 do
    if Fields[I].FieldKind = fkLookup then
      //////Do Whaever here.  This would be a foreign key
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1363716
Hi heathprovost,

really? is this kind not used for the lookup-components?

meikl
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:GGriffith
ID: 1363717
Using Sybase SQL Anywhere....on a Windows 95/98/NT platform...
I looked at using the FIELDKIND, but it doesn't seem to offer a way to identify the field as being a foreign key...Any other ideas?

0
 
LVL 1

Accepted Solution

by:
velev earned 50 total points
ID: 1363718
most of the SQL servers ()has system tables in
which they stores information about relations triggers, dependencies, domains, foreign keys and so on
you have to find out this tables for your server ( with SQLExpolorer for example (in view menu click show system tables))
and retrieve info from them (be carefull with "write" operation in this tables)
0
 
LVL 5

Expert Comment

by:heathprovost
ID: 1363719
Sorry about that, I wasnt thinking clearly, hadnt had my coffee yet :)

Heath
0
 
LVL 5

Expert Comment

by:heathprovost
ID: 1363720
One other thought.  Many RDBMS's by default will name foreign keys a certain way (i.e. FK_something).  If this is the case with your system you could cycle through all of the IndexDefs and check the name property.  Just a thought

Heath
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 110
Correct Component for Shopping Cart. 2 121
URL for downloading Google Chrome for Win XP 2 232
Firemonkey BASS_Init into a thread 17 53
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question