public TableSchema[] GetTables(string connectionString, DatabaseSchema database)
        {
            var tables             = new List <TableSchema>();
            var extendedProperties = new List <ExtendedProperty>();

            using (IVistaDBDatabase vistaDb = GetDatabase(connectionString))
            {
                if (vistaDb == null)
                {
                    return(tables.ToArray());
                }

                foreach (string tableName in vistaDb.GetTableNames())
                {
                    IVistaDBTableSchema table = vistaDb.TableSchema(tableName);
                    if (table == null)
                    {
                        continue;
                    }

                    extendedProperties.Clear();
                    extendedProperties.Add(ExtendedProperty.Readonly(ExtendedPropertyNames.Description, table.Description));

                    var tableSchema = new TableSchema(database, table.Name, String.Empty, DateTime.MinValue, extendedProperties.ToArray());

                    tables.Add(tableSchema);
                }
            }

            return(tables.ToArray());
        }
Exemplo n.º 2
0
        DataTable IMyMetaPlugin.GetTables(string database)
        {
            DataTable        metaData = new DataTable();
            IVistaDBDatabase db       = null;

            try
            {
                metaData = context.CreateTablesDataTable();

                db = DDA.OpenDatabase(this.GetFullDatabaseName(),
                                      VistaDBDatabaseOpenMode.NonexclusiveReadOnly, "");

                ArrayList tables = db.EnumTables();

                foreach (string table in tables)
                {
                    IVistaDBTableSchema tblStructure = db.TableSchema(table);

                    DataRow row = metaData.NewRow();
                    metaData.Rows.Add(row);

                    row["TABLE_NAME"]  = tblStructure.Name;
                    row["DESCRIPTION"] = tblStructure.Description;
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(metaData);
        }
        public TableKeySchema[] GetTableKeys(string connectionString, TableSchema table)
        {
            var keys               = new List <TableKeySchema>();
            var foreignColumns     = new List <string>();
            var primaryColumns     = new List <string>();
            var extendedProperties = new List <ExtendedProperty>();

            using (IVistaDBDatabase vistaDb = GetDatabase(connectionString))
            {
                if (vistaDb == null)
                {
                    return(keys.ToArray());
                }

                IVistaDBTableSchema vistaTable = vistaDb.TableSchema(table.Name);
                if (vistaTable == null)
                {
                    return(keys.ToArray());
                }

                foreach (IVistaDBRelationshipInformation vistaKey in vistaTable.ForeignKeys)
                {
                    foreignColumns.Clear();
                    foreignColumns.AddRange(vistaKey.ForeignKey.Split(
                                                new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));

                    IVistaDBTableSchema vistaPrimaryTable = vistaDb.TableSchema(vistaKey.PrimaryTable);
                    if (vistaPrimaryTable == null)
                    {
                        continue;
                    }

                    primaryColumns.Clear();
                    //find primary key index
                    foreach (IVistaDBIndexInformation i in vistaPrimaryTable.Indexes)
                    {
                        if (i.Primary)
                        {
                            primaryColumns.AddRange(i.KeyExpression.Split(
                                                        new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
                        }
                    }

                    extendedProperties.Clear();
                    extendedProperties.Add(ExtendedProperty.Readonly(ExtendedPropertyNames.Description, vistaKey.Description));

                    var key = new TableKeySchema(
                        table.Database, vistaKey.Name,
                        foreignColumns.ToArray(),
                        string.Empty, vistaKey.ForeignTable,
                        primaryColumns.ToArray(),
                        string.Empty, vistaKey.PrimaryTable,
                        extendedProperties.ToArray());

                    keys.Add(key);
                }
            }

            return(keys.ToArray());
        }
        public PrimaryKeySchema GetTablePrimaryKey(string connectionString, TableSchema table)
        {
            using (IVistaDBDatabase vistaDb = GetDatabase(connectionString))
            {
                if (vistaDb == null)
                {
                    return(null);
                }

                IVistaDBTableSchema vistaTable = vistaDb.TableSchema(table.Name);
                if (vistaTable == null)
                {
                    return(null);
                }

                foreach (IVistaDBIndexInformation vistaIndex in vistaTable.Indexes)
                {
                    if (!vistaIndex.Primary)
                    {
                        continue;
                    }

                    var key = new PrimaryKeySchema(
                        table, vistaIndex.Name,
                        vistaIndex.KeyExpression.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));

                    return(key);
                }
            }

            return(null);
        }
Exemplo n.º 5
0
        public void Open(string connectionString)
        {
            if (this.db == null)
            {
                this.connectionString = connectionString;

                this.dda = VistaDBEngine.Connections.OpenDDA();

                if (!System.IO.File.Exists(connectionString))
                {
                    // create database
                    this.db = this.dda.CreateDatabase(connectionString, true, null, 0, 0, false);

                    #region table structures
                    IVistaDBTableSchema tbSchema = this.db.NewTable("InnerRelations");
                    tbSchema.AddColumn("id", VistaDBType.BigInt);
                    tbSchema.DefineColumnAttributes("id", false, false, false, false, null, null);
                    tbSchema.AddColumn("nParentId", VistaDBType.BigInt);
                    tbSchema.DefineColumnAttributes("nParentId", false, false, false, false, null, null);
                    tbSchema.AddColumn("aParentId", VistaDBType.BigInt);
                    tbSchema.DefineColumnAttributes("aParentId", false, false, false, false, null, null);
                    tbSchema.AddColumn("qualifierId", VistaDBType.BigInt);
                    tbSchema.DefineColumnAttributes("qualifierId", false, false, false, false, null, null);
                    this.tbInnerRelations = this.db.CreateTable(tbSchema, false, false);

                    tbSchema = this.db.NewTable("RootRelations");
                    tbSchema.AddColumn("id", VistaDBType.BigInt);
                    tbSchema.DefineColumnAttributes("id", false, false, false, false, null, null);
                    tbSchema.AddColumn("terminalValue", VistaDBType.VarChar);
                    tbSchema.DefineColumnAttributes("terminalValue", false, false, false, false, null, null);
                    tbSchema.AddColumn("qualifierId", VistaDBType.BigInt);
                    tbSchema.DefineColumnAttributes("qualifierId", false, false, false, false, null, null);
                    this.tbRootRelations = this.db.CreateTable(tbSchema, false, false);
                    #endregion

                    #region indexes
                    this.tbInnerRelations.CreateIdentity("id", "1", "1");
                    this.tbInnerRelations.CreateIndex("findById", "id", true, true);
                    this.tbInnerRelations.CreateIndex("findByParents", "nParentId;aParentId", false, true);
                    this.tbInnerRelations.CreateIndex("findByAParent", "aParentId", false, false);
                    this.tbInnerRelations.CreateIndex("findByQualifier", "qualifierId", false, false);

                    this.tbRootRelations.CreateIdentity("id", "-1", "-1");
                    this.tbRootRelations.CreateIndex("findById", "id", true, true);
                    this.tbRootRelations.CreateIndex("findByTerminalValue", "terminalValue", false, true);
                    this.tbRootRelations.CreateIndex("findByQualifier", "qualifierId", false, false);
                    #endregion
                }
                else
                {
                    // open existing database
                    this.db = this.dda.OpenDatabase(connectionString, VistaDBDatabaseOpenMode.ExclusiveReadWrite, null);
                    this.tbInnerRelations = this.db.OpenTable("InnerRelations", false, false);
                    this.tbRootRelations  = this.db.OpenTable("RootRelations", false, false);
                }
            }
        }
        public ColumnSchema[] GetTableColumns(string connectionString, TableSchema table)
        {
            var columns            = new List <ColumnSchema>();
            var extendedProperties = new List <ExtendedProperty>();

            using (IVistaDBDatabase vistaDb = GetDatabase(connectionString))
            {
                if (vistaDb == null)
                {
                    return(columns.ToArray());
                }

                IVistaDBTableSchema vistaTable = vistaDb.TableSchema(table.Name);
                if (vistaTable == null)
                {
                    return(columns.ToArray());
                }

                foreach (IVistaDBColumnAttributes vistaColumn in vistaTable)
                {
                    string nativeType = vistaColumn.Type.ToString();

                    extendedProperties.Clear();
                    extendedProperties.Add(ExtendedProperty.Readonly(ExtendedPropertyNames.Description, vistaColumn.Description));
                    extendedProperties.Add(ExtendedProperty.Readonly(ExtendedPropertyNames.ObjectID, vistaColumn.UniqueId));
                    extendedProperties.Add(ExtendedProperty.Readonly(ExtendedPropertyNames.DefaultValue, ""));
                    extendedProperties.Add(ExtendedProperty.Readonly("CS_CodePage", vistaColumn.CodePage));
                    extendedProperties.Add(ExtendedProperty.Readonly("CS_Encrypted", vistaColumn.Encrypted));
                    extendedProperties.Add(ExtendedProperty.Readonly("CS_Packed", vistaColumn.Packed));
                    extendedProperties.Add(ExtendedProperty.Readonly("CS_ReadOnly", vistaColumn.ReadOnly));

                    bool isIdentity = false;
                    foreach (IVistaDBIdentityInformation identity in vistaTable.Identities)
                    {
                        isIdentity = (identity.ColumnName == vistaColumn.Name);
                        if (isIdentity)
                        {
                            break;
                        }
                    }

                    extendedProperties.Add(ExtendedProperty.Readonly(ExtendedPropertyNames.IsIdentity, isIdentity));

                    var column = new ColumnSchema(table, vistaColumn.Name, GetDbType(nativeType),
                                                  nativeType, vistaColumn.MaxLength, 0, 0, vistaColumn.AllowNull,
                                                  extendedProperties.ToArray());

                    columns.Add(column);
                }
            }


            return(columns.ToArray());
        }
Exemplo n.º 7
0
        List <string> IPlugin.GetPrimaryKeyColumns(string database, string table)
        {
            List <string>    primaryKeys = new List <string>();
            IVistaDBDatabase db          = null;

            try
            {
                using (VistaDBConnection cn = new VistaDBConnection(context.ConnectionString))
                {
                    db = DDA.OpenDatabase(this.GetFullDatabaseName(), VistaDBDatabaseOpenMode.NonexclusiveReadOnly, GetPassword(cn));
                }

                IVistaDBTableSchema tblStructure = db.TableSchema(table);

                string[] pks = null;
                if (tblStructure.Indexes.Contains("PrimaryKey"))
                {
                    pks = tblStructure.Indexes["PrimaryKey"].KeyExpression.Split(';');
                }
                else
                {
                    foreach (IVistaDBIndexInformation pk in tblStructure.Indexes)
                    {
                        if (pk.Primary)
                        {
                            pks = pk.KeyExpression.Split(';');
                            break;
                        }
                    }
                }

                if (pks != null)
                {
                    foreach (string pkColName in pks)
                    {
                        primaryKeys.Add(pkColName);
                    }
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(primaryKeys);
        }
Exemplo n.º 8
0
        DataTable IPlugin.GetTableIndexes(string database, string table)
        {
            DataTable        metaData = new DataTable();
            IVistaDBDatabase db       = null;

            try
            {
                metaData = context.CreateIndexesDataTable();

                using (VistaDBConnection cn = new VistaDBConnection(context.ConnectionString))
                {
                    db = DDA.OpenDatabase(this.GetFullDatabaseName(), VistaDBDatabaseOpenMode.NonexclusiveReadOnly, GetPassword(cn));
                }

                ArrayList tables = db.EnumTables();

                IVistaDBTableSchema tblStructure = db.TableSchema(table);

                foreach (IVistaDBIndexInformation indexInfo in tblStructure.Indexes)
                {
                    string[] pks = indexInfo.KeyExpression.Split(';');

                    int index = 0;
                    foreach (string colName in pks)
                    {
                        DataRow row = metaData.NewRow();
                        metaData.Rows.Add(row);

                        row["TABLE_CATALOG"] = GetDatabaseName();
                        row["TABLE_NAME"]    = tblStructure.Name;
                        row["INDEX_CATALOG"] = GetDatabaseName();
                        row["INDEX_NAME"]    = indexInfo.Name;
                        row["UNIQUE"]        = indexInfo.Unique;
                        row["COLLATION"]     = indexInfo.KeyStructure[index++].Descending ? 2 : 1;
                        row["COLUMN_NAME"]   = colName;
                    }
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(metaData);
        }
        public IndexSchema[] GetTableIndexes(string connectionString, TableSchema table)
        {
            var indexes            = new List <IndexSchema>();
            var memberColumns      = new List <string>();
            var extendedProperties = new List <ExtendedProperty>();

            using (IVistaDBDatabase vistaDb = GetDatabase(connectionString))
            {
                if (vistaDb == null)
                {
                    return(indexes.ToArray());
                }

                IVistaDBTableSchema vistaTable = vistaDb.TableSchema(table.Name);
                if (vistaTable == null)
                {
                    return(indexes.ToArray());
                }

                foreach (IVistaDBIndexInformation vistaIndex in vistaTable.Indexes)
                {
                    memberColumns.Clear();
                    foreach (IVistaDBKeyColumn keyColumn in vistaIndex.KeyStructure)
                    {
                        memberColumns.Add(vistaTable[keyColumn.RowIndex].Name);
                    }

                    extendedProperties.Clear();
                    extendedProperties.Add(ExtendedProperty.Readonly(ExtendedPropertyNames.Description, vistaIndex.Description));
                    extendedProperties.Add(ExtendedProperty.Readonly("CS_FastTextSearch", vistaIndex.FullTextSearch));

                    var index = new IndexSchema(table, vistaIndex.Name, vistaIndex.Primary,
                                                vistaIndex.Unique, false,
                                                memberColumns.ToArray(),
                                                extendedProperties.ToArray());

                    indexes.Add(index);
                }
            }

            return(indexes.ToArray());
        }
Exemplo n.º 10
0
        DataTable IPlugin.GetTables(string database)
        {
            DataTable        metaData = new DataTable();
            IVistaDBDatabase db       = null;

            try
            {
                metaData = context.CreateTablesDataTable();

                using (VistaDBConnection cn = new VistaDBConnection(context.ConnectionString))
                {
                    db = DDA.OpenDatabase(this.GetFullDatabaseName(), VistaDBDatabaseOpenMode.NonexclusiveReadOnly, GetPassword(cn));
                }

                IVistaDBTableNameCollection tables = db.GetTableNames();

                foreach (string table in tables)
                {
                    IVistaDBTableSchema tblStructure = db.TableSchema(table);

                    DataRow row = metaData.NewRow();
                    metaData.Rows.Add(row);

                    row["TABLE_NAME"]  = tblStructure.Name;
                    row["DESCRIPTION"] = tblStructure.Description;
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(metaData);
        }
Exemplo n.º 11
0
        DataTable IPlugin.GetForeignKeys(string database, string tableName)
        {
            DataTable        metaData = new DataTable();
            IVistaDBDatabase db       = null;

            try
            {
                metaData = context.CreateForeignKeysDataTable();

                using (VistaDBConnection cn = new VistaDBConnection(context.ConnectionString))
                {
                    db = DDA.OpenDatabase(this.GetFullDatabaseName(), VistaDBDatabaseOpenMode.NonexclusiveReadOnly, GetPassword(cn));
                }

                ArrayList tables = db.EnumTables();

                foreach (string table in tables)
                {
                    IVistaDBTableSchema tblStructure = db.TableSchema(table);

                    //==================================================================
                    // This works around a change that was made to the VistaDB provider
                    // It's ugly, we know
                    //==================================================================
                    IEnumerator enumerator = null;

                    if (useOldForeignKeyWay)
                    {
                        enumerator = tblStructure.ForeignKeys.GetEnumerator();
                    }
                    else
                    {
                        try
                        {
                            enumerator = tblStructure.ForeignKeys.Values.GetEnumerator();
                        }
                        catch
                        {
                            enumerator          = tblStructure.ForeignKeys.GetEnumerator();
                            useOldForeignKeyWay = true;
                        }
                    }

                    // Okay, now that the version issues are over we just use the 'enumerator'
                    while (enumerator.MoveNext())
                    {
                        IVistaDBRelationshipInformation relInfo = enumerator.Current as IVistaDBRelationshipInformation;

                        if (relInfo.ForeignTable != tableName && relInfo.PrimaryTable != tableName)
                        {
                            continue;
                        }

                        string fCols = relInfo.ForeignKey;
                        string pCols = String.Empty;

                        string primaryTbl = relInfo.PrimaryTable;
                        string pkName     = "";

                        using (IVistaDBTableSchema pkTableStruct = db.TableSchema(primaryTbl))
                        {
                            foreach (IVistaDBIndexInformation idxInfo in pkTableStruct.Indexes)
                            {
                                if (!idxInfo.Primary)
                                {
                                    continue;
                                }

                                pkName = idxInfo.Name;
                                pCols  = idxInfo.KeyExpression;
                                break;
                            }
                        }

                        string [] fColumns = fCols.Split(';');
                        string [] pColumns = pCols.Split(';');

                        for (int i = 0; i < fColumns.GetLength(0); i++)
                        {
                            DataRow row = metaData.NewRow();
                            metaData.Rows.Add(row);

                            row["PK_TABLE_CATALOG"] = GetDatabaseName();
                            row["PK_TABLE_SCHEMA"]  = DBNull.Value;
                            row["FK_TABLE_CATALOG"] = DBNull.Value;
                            row["FK_TABLE_SCHEMA"]  = DBNull.Value;
                            row["FK_TABLE_NAME"]    = tblStructure.Name;
                            row["PK_TABLE_NAME"]    = relInfo.PrimaryTable;
                            row["ORDINAL"]          = 0;
                            row["FK_NAME"]          = relInfo.Name;
                            row["PK_NAME"]          = pkName;
                            row["PK_COLUMN_NAME"]   = pColumns[i];
                            row["FK_COLUMN_NAME"]   = fColumns[i];

                            row["UPDATE_RULE"] = relInfo.UpdateIntegrity;
                            row["DELETE_RULE"] = relInfo.DeleteIntegrity;
                        }
                    }
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(metaData);
        }
Exemplo n.º 12
0
        DataTable IPlugin.GetTableColumns(string database, string table)
        {
            DataTable        metaData = new DataTable();
            IVistaDBDatabase db       = null;

            try
            {
                metaData = context.CreateColumnsDataTable();

                using (VistaDBConnection cn = new VistaDBConnection(context.ConnectionString))
                {
                    db = DDA.OpenDatabase(this.GetFullDatabaseName(), VistaDBDatabaseOpenMode.NonexclusiveReadOnly, GetPassword(cn));
                }

                ArrayList tables = db.EnumTables();

                IVistaDBTableSchema tblStructure = db.TableSchema(table);

                foreach (IVistaDBColumnAttributes c in tblStructure)
                {
                    string colName = c.Name;

                    string def = "";
                    if (tblStructure.Defaults.Contains(colName))
                    {
                        def = tblStructure.Defaults[colName].Expression;
                    }
                    int width     = c.MaxLength;                     //c.ColumnWidth;
                    int dec       = 0;                               //c.ColumnDecimals;
                    int length    = 0;
                    int octLength = width;

                    IVistaDBIdentityInformation identity = null;
                    if (tblStructure.Identities.Contains(colName))
                    {
                        identity = tblStructure.Identities[colName];
                    }

                    string[] pks = null;
                    if (tblStructure.Indexes.Contains("PrimaryKey"))
                    {
                        pks = tblStructure.Indexes["PrimaryKey"].KeyExpression.Split(';');
                    }
                    else
                    {
                        foreach (IVistaDBIndexInformation pk in tblStructure.Indexes)
                        {
                            if (pk.Primary)
                            {
                                pks = pk.KeyExpression.Split(';');
                                break;
                            }
                        }
                    }

                    System.Collections.Hashtable pkCols = null;
                    if (pks != null)
                    {
                        pkCols = new Hashtable();
                        foreach (string pkColName in pks)
                        {
                            pkCols[pkColName] = true;
                        }
                    }

                    switch (c.Type)
                    {
                    case VistaDBType.Char:
                    case VistaDBType.NChar:
                    case VistaDBType.NText:
                    case VistaDBType.NVarChar:
                    case VistaDBType.Text:
                    case VistaDBType.VarChar:
                        length = width;
                        width  = 0;
                        dec    = 0;
                        break;

                    case VistaDBType.Money:
                    case VistaDBType.Float:
                    case VistaDBType.Decimal:
                    case VistaDBType.Real:
                        break;

                    default:
                        width = 0;
                        dec   = 0;
                        break;
                    }

                    DataRow row = metaData.NewRow();
                    metaData.Rows.Add(row);

                    row["TABLE_NAME"]               = tblStructure.Name;
                    row["COLUMN_NAME"]              = c.Name;
                    row["ORDINAL_POSITION"]         = c.RowIndex;
                    row["IS_NULLABLE"]              = c.AllowNull;
                    row["COLUMN_HASDEFAULT"]        = def == string.Empty ? false : true;
                    row["COLUMN_DEFAULT"]           = def;
                    row["IS_AUTO_KEY"]              = identity == null ? false : true;
                    row["AUTO_KEY_SEED"]            = 1;
                    row["AUTO_KEY_INCREMENT"]       = identity == null ? 0 : Convert.ToInt32(identity.StepExpression);
                    row["TYPE_NAME"]                = c.Type.ToString();
                    row["NUMERIC_PRECISION"]        = width;
                    row["NUMERIC_SCALE"]            = dec;
                    row["CHARACTER_MAXIMUM_LENGTH"] = length;
                    row["CHARACTER_OCTET_LENGTH"]   = octLength;
                    row["DESCRIPTION"]              = c.Description;

                    string type = (string)row["TYPE_NAME"];
                    row["TYPE_NAME_COMPLETE"] = this.GetDataTypeNameComplete(type, length, (short)width, (short)dec);

                    if (c.Type == VistaDBType.Timestamp)
                    {
                        row["IS_COMPUTED"] = true;
                    }

                    row["IS_CONCURRENCY"] = type == "Timestamp" ? true : false;
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(metaData);
        }
Exemplo n.º 13
0
        DataTable IMyMetaPlugin.GetForeignKeys(string database, string tableName)
        {
            DataTable        metaData = new DataTable();
            IVistaDBDatabase db       = null;

            try
            {
                metaData = context.CreateForeignKeysDataTable();

                db = DDA.OpenDatabase(this.GetFullDatabaseName(),
                                      VistaDBDatabaseOpenMode.NonexclusiveReadOnly, "");

                ArrayList tables = db.EnumTables();

                foreach (string table in tables)
                {
                    IVistaDBTableSchema tblStructure = db.TableSchema(table);

                    foreach (IVistaDBRelationshipInformation relInfo in tblStructure.ForeignKeys)
                    {
                        if (relInfo.ForeignTable != tableName && relInfo.PrimaryTable != tableName)
                        {
                            continue;
                        }

                        string fCols = relInfo.ForeignKey;
                        string pCols = String.Empty;

                        string primaryTbl = relInfo.PrimaryTable;
                        string pkName     = "";

                        using (IVistaDBTableSchema pkTableStruct = db.TableSchema(primaryTbl))
                        {
                            foreach (IVistaDBIndexInformation idxInfo in pkTableStruct.Indexes)
                            {
                                if (!idxInfo.Primary)
                                {
                                    continue;
                                }

                                pkName = idxInfo.Name;
                                pCols  = idxInfo.KeyExpression;
                                break;
                            }
                        }

                        string [] fColumns = fCols.Split(';');
                        string [] pColumns = pCols.Split(';');

                        for (int i = 0; i < fColumns.GetLength(0); i++)
                        {
                            DataRow row = metaData.NewRow();
                            metaData.Rows.Add(row);

                            row["PK_TABLE_CATALOG"] = GetDatabaseName();
                            row["PK_TABLE_SCHEMA"]  = DBNull.Value;
                            row["FK_TABLE_CATALOG"] = DBNull.Value;
                            row["FK_TABLE_SCHEMA"]  = DBNull.Value;
                            row["FK_TABLE_NAME"]    = tblStructure.Name;
                            row["PK_TABLE_NAME"]    = relInfo.PrimaryTable;
                            row["ORDINAL"]          = 0;
                            row["FK_NAME"]          = relInfo.Name;
                            row["PK_NAME"]          = pkName;
                            row["PK_COLUMN_NAME"]   = pColumns[i];
                            row["FK_COLUMN_NAME"]   = fColumns[i];

                            row["UPDATE_RULE"] = relInfo.UpdateIntegrity;
                            row["DELETE_RULE"] = relInfo.DeleteIntegrity;
                        }
                    }
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(metaData);
        }