V,
The code gives a list of all of the foreign-key references in the database, along with the parent table, parent column(s), child table, and child column(s). It's basically a list of the relationships that you've established in your database.
If you aren't getting any results, it means that there are no foreign-key constraints on any of the tables in your database - i.e. there are no relationships.
>Hi
>
>Thank for the infor, but how do I use it
>I don't get any result when run under
>my database. Please advise.
>
>Thank you
>
>>V,
>>
>>The data you are after is already stored in the INFORMATION_SCHEMA tables:
>>
>>
>>select
>> ccu.table_catalog + '.' + ccu.table_schema + '.' + ccu.table_name as ChildTable,
>> ccu.column_name as ChildColumn,
>> ctu.table_catalog + '.' + ctu.table_schema + '.' + ctu.table_name as ParentTable,
>> ccu1.column_name as ParentColumn,
>> ccu.constraint_name as ConstraintName,
>> rc.match_option,
>> rc.update_rule,
>> rc.delete_rule
>>from information_schema.referential_constraints rc
>> inner join information_schema.constraint_column_usage ccu
>> on ccu.constraint_name = rc.constraint_name
>> inner join information_schema.constraint_table_usage ctu
>> on ctu.constraint_name = rc.unique_constraint_name
>> inner join information_schema.constraint_column_usage ccu1
>> on ccu1.constraint_name = ctu.constraint_name
>>order by
>> ChildTable,
>> ChildColumn,
>> ParentTable,
>> ParentColumn
>>
>>
>>>Hi,
>>>
>>>Anyone have done the following database design,
>>>
>>> -All the tables in a database relationship(primary & foreign key) and link are
>>> save in a table for fast reference.
>>>
>>>I need some reference on how to do the above mentioned design
>>>as my application need fast reference to which table is related to
>>>which table and any changes, which table will be affected. I don't
>>>refer to use trigger as I have lot of tables.
>>>
>>>I am designing my own but want to know from other which might
>>>give me a better design concept and ideas.
>>>
>>>Thank in advance.