Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 20th, 2004, 12:00 PM
WayneB WayneB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Cape Town, South Africa
Posts: 51 WayneB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 42 m 31 sec
Reputation Power: 5
Send a message via Skype to WayneB
How to distinguish between 1:1, 1:m Fk's

Hi All

I am retreiving FK's from a FB database, but now i need to know weather the FK's are 1:1, 1:m or what ever.

Here is the sql that i have at the momment. How would i go about retreiving only the 1:1 and then the 1:m in different SQL statements? In MS Sql 2000 there is flags in the Information schema tables that will give me this info, but how do i find this out with FB?

select A.RDB$RELATION_NAME,
A.RDB$CONSTRAINT_NAME,
A.RDB$CONSTRAINT_TYPE,
B.RDB$CONST_NAME_UQ,
B.RDB$UPDATE_RULE,
B.RDB$DELETE_RULE,
C.RDB$RELATION_NAME as FK_Table,
A.RDB$INDEX_NAME,
D.RDB$FIELD_NAME as FK_Field,
E.RDB$FIELD_NAME as OnField,
I.RDB$INDEX_TYPE
from RDB$REF_CONSTRAINTS B, RDB$RELATION_CONSTRAINTS A, RDB$RELATION_CONSTRAINTS C,
RDB$INDEX_SEGMENTS D, RDB$INDEX_SEGMENTS E, RDB$INDICES I
where (A.RDB$CONSTRAINT_TYPE = 'FOREIGN KEY') and
(A.RDB$CONSTRAINT_NAME = B.RDB$CONSTRAINT_NAME) and
(B.RDB$CONST_NAME_UQ=C.RDB$CONSTRAINT_NAME) and (C.RDB$INDEX_NAME=D.RDB$INDEX_NAME) and
(A.RDB$INDEX_NAME=E.RDB$INDEX_NAME) and
(A.RDB$INDEX_NAME=I.RDB$INDEX_NAME)
and (A.RDB$RELATION_NAME = 'JOB')
order by A.RDB$RELATION_NAME, A.RDB$CONSTRAINT_NAME, D.RDB$FIELD_POSITION, E.RDB$FIELD_POSITION

Thanks Wayne

Reply With Quote
  #2  
Old June 23rd, 2004, 02:36 AM
WayneB WayneB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Cape Town, South Africa
Posts: 51 WayneB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 42 m 31 sec
Reputation Power: 5
Send a message via Skype to WayneB
Smile

Don't worry guys.

I found the info that i needed.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > How to distinguish between 1:1, 1:m Fk's


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT