Client Interfaces Guide > TIBCO ADO.NET 2020 Data Provider for TDV > Schema Discovery > Foreign Keys
 
Foreign Keys
This section describes how to access information about foreign keys by retrieving the ForeignKeys schema collection.
 
Retrieving Foreign Key Information
To retrieve the ForeignKeys schema collection, call the GetSchema method of the CompositeConnection class. You can restrict foreign key information by the table name.
Access the results in the DataTable returned. The following example lists the foreign keys for the Products table.
C#
 
String connectionString = "Host=myHost;Domain=myDomain;DataSource=myDataSource;User=myUser;Password=myPassword";
using (CompositeConnection conn = new CompositeConnection(connectionString)) {
conn.Open();
DataTable databaseSchema = conn.GetSchema("ForeignKeys", new string[] {"Products"});
foreach (DataRow row in databaseSchema.Rows) {
Console.WriteLine(row["CONSTRAINT_NAME"]);
Console.WriteLine(row["TABLE_NAME"]);
}
}
VB.NET
 
Dim connectionString As String = "Host=myHost;Domain=myDomain;DataSource=myDataSource;User=myUser;Password=myPassword"
Using conn As New CompositeConnection(connectionString)
conn.Open()
Dim databaseSchema As DataTable = conn.GetSchema("ForeignKeys", New String() {"Products"})
For Each row As DataRow In databaseSchema.Rows
Console.WriteLine(row("CONSTRAINT_NAME"))
Console.WriteLine(row("TABLE_NAME"))
Next
End Using
Columns Returned
The ForeignKeys schema collection returns the following information about the foreign keys in TDV.
Column Name
Data Type
Description
CONSTRAINT_CATALOG
System.String
The database containing the foreign key.
CONSTRAINT_SCHEMA
System.String
The schema containing the foreign key.
CONSTRAINT_NAME
System.String
The name of the foreign key.
CONSTRAINT_TYPE
System.String
Returns FOREIGN KEY.
TABLE_CATALOG
System.String
The database of the table containing the foreign key.
TABLE_SCHEMA
System.String
The schema of the table containing the foreign key.
TABLE_NAME
System.String
The name of the table containing the foreign key.
IS_DEFERRABLE
System.String
Whether the foreign key is deferrable. This value is YES or NO.
INITIALLY_DEFERRED
System.String
Whether the foreign is initially deferrable. This value is YES or NO.