示例#1
0
        public static void Setup(ITransaction transaction)
        {
            // -- Primary Keys --
            // The 'id' columns are primary keys on all the system tables,
            var idCol = new[] { "id" };

            transaction.AddPrimaryKey(PrimaryKeyInfoTableName, idCol, "SYSTEM_PK_PK");
            transaction.AddPrimaryKey(ForeignKeyInfoTableName, idCol, "SYSTEM_FK_PK");
            transaction.AddPrimaryKey(UniqueKeyInfoTableName, idCol, "SYSTEM_UNIQUE_PK");
            transaction.AddPrimaryKey(CheckInfoTableName, idCol, "SYSTEM_CHECK_PK");
            transaction.AddPrimaryKey(SchemaInfoTableName, idCol, "SYSTEM_SCHEMA_PK");

            // -- Foreign Keys --
            // Create the foreign key references,
            var fkCol    = new string[1];
            var fkRefCol = new[] { "id" };

            fkCol[0] = "pk_id";
            transaction.AddForeignKey(PrimaryKeyColumnsTableName, fkCol, PrimaryKeyInfoTableName, fkRefCol, "SYSTEM_PK_FK");

            fkCol[0] = "fk_id";
            transaction.AddForeignKey(ForeignKeyColumnsTableName, fkCol, ForeignKeyInfoTableName, fkRefCol, "SYSTEM_FK_FK");

            fkCol[0] = "un_id";
            transaction.AddForeignKey(UniqueKeyColumnsTableName, fkCol, UniqueKeyInfoTableName, fkRefCol, "SYSTEM_UNIQUE_FK");

            // pkey_info 'schema', 'table' column is a unique set,
            // (You are only allowed one primary key per table).
            var columns = new[] { "schema", "table" };

            transaction.AddUniqueKey(PrimaryKeyInfoTableName, columns, "SYSTEM_PKEY_ST_UNIQUE");

            // schema_info 'name' column is a unique column,
            columns = new String[] { "name" };
            transaction.AddUniqueKey(SchemaInfoTableName, columns, "SYSTEM_SCHEMA_UNIQUE");

            //    columns = new String[] { "name" };
            columns = new String[] { "name", "schema" };
            // pkey_info 'name' column is a unique column,
            transaction.AddUniqueKey(PrimaryKeyInfoTableName, columns, "SYSTEM_PKEY_UNIQUE");

            // fkey_info 'name' column is a unique column,
            transaction.AddUniqueKey(ForeignKeyInfoTableName, columns, "SYSTEM_FKEY_UNIQUE");

            // unique_info 'name' column is a unique column,
            transaction.AddUniqueKey(UniqueKeyInfoTableName, columns, "SYSTEM_UNIQUE_UNIQUE");

            // check_info 'name' column is a unique column,
            transaction.AddUniqueKey(CheckInfoTableName, columns, "SYSTEM_CHECK_UNIQUE");
        }
示例#2
0
        public static void Setup(ITransaction transaction)
        {
            // -- Primary Keys --
            // The 'id' columns are primary keys on all the system tables,
            var idCol = new[] { "id" };
            transaction.AddPrimaryKey(PrimaryKeyInfoTableName, idCol, "SYSTEM_PK_PK");
            transaction.AddPrimaryKey(ForeignKeyInfoTableName, idCol, "SYSTEM_FK_PK");
            transaction.AddPrimaryKey(UniqueKeyInfoTableName, idCol, "SYSTEM_UNIQUE_PK");
            transaction.AddPrimaryKey(CheckInfoTableName, idCol, "SYSTEM_CHECK_PK");
            transaction.AddPrimaryKey(SchemaInfoTableName, idCol, "SYSTEM_SCHEMA_PK");

            // -- Foreign Keys --
            // Create the foreign key references,
            var fkCol = new string[1];
            var fkRefCol = new[] { "id" };

            fkCol[0] = "pk_id";
            transaction.AddForeignKey(PrimaryKeyColumnsTableName, fkCol, PrimaryKeyInfoTableName, fkRefCol, "SYSTEM_PK_FK");

            fkCol[0] = "fk_id";
            transaction.AddForeignKey(ForeignKeyColumnsTableName, fkCol, ForeignKeyInfoTableName, fkRefCol, "SYSTEM_FK_FK");

            fkCol[0] = "un_id";
            transaction.AddForeignKey(UniqueKeyColumnsTableName, fkCol, UniqueKeyInfoTableName, fkRefCol, "SYSTEM_UNIQUE_FK");

            // pkey_info 'schema', 'table' column is a unique set,
            // (You are only allowed one primary key per table).
            var columns = new[] { "schema", "table" };
            transaction.AddUniqueKey(PrimaryKeyInfoTableName, columns, "SYSTEM_PKEY_ST_UNIQUE");

            // schema_info 'name' column is a unique column,
            columns = new String[] { "name" };
            transaction.AddUniqueKey(SchemaInfoTableName, columns, "SYSTEM_SCHEMA_UNIQUE");

            //    columns = new String[] { "name" };
            columns = new String[] { "name", "schema" };
            // pkey_info 'name' column is a unique column,
            transaction.AddUniqueKey(PrimaryKeyInfoTableName, columns, "SYSTEM_PKEY_UNIQUE");

            // fkey_info 'name' column is a unique column,
            transaction.AddUniqueKey(ForeignKeyInfoTableName, columns, "SYSTEM_FKEY_UNIQUE");

            // unique_info 'name' column is a unique column,
            transaction.AddUniqueKey(UniqueKeyInfoTableName, columns, "SYSTEM_UNIQUE_UNIQUE");

            // check_info 'name' column is a unique column,
            transaction.AddUniqueKey(CheckInfoTableName, columns, "SYSTEM_CHECK_UNIQUE");
        }