Solved

Table Structures (Foreign Keys)

Posted on 1999-01-28
7
241 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
A short film showing how OnPage and Connectwise integration works.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

914 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now