Solved

Table Structures (Foreign Keys)

Posted on 1999-01-28
7
245 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error 1.1 400 Bad request idhttp delphi 18 277
Making delphi communicate with a c# service 16 138
Delphi Yen format 3 74
Convert MS Word document to a PDF file 9 136
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…

739 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