Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Table Structures (Foreign Keys)

Posted on 1999-01-28
7
Medium Priority
?
247 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
Technology Partners: 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 150 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

Technology Partners: 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!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

704 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