Ejemplo n.º 1
0
        /// <summary>
        /// Constructor using Main and Reference Table.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="main"></param>
        /// <param name="child"></param>
        /// <param name="columnMain"></param>
        /// <param name="columnRef"></param>
        public Constraint(ConstraintType type, Table main, Table child, int[] columnMain, int[] columnRef)
        {
            _type        = type;
            _mainTable   = main;
            _refTable    = child;
            _mainColumns = columnMain;
            _refColumns  = columnRef;
            _len         = columnMain.Length;

            if (Trace.AssertEnabled)
            {
                Trace.Assert(columnMain.Length == columnRef.Length);
            }

            _mainData  = _mainTable.NewRow;
            _refData   = _refTable.NewRow;
            _mainIndex = _mainTable.GetIndexForColumns(columnMain);
            _refIndex  = _refTable.GetIndexForColumns(columnRef);
        }
Ejemplo n.º 2
0
        private void AddForeignKeyOn(Tokenizer tokenizer, Channel channel, string name, Table table)
        {
            int[] col = ProcessColumnList(tokenizer, table);

            tokenizer.GetThis("REFERENCES");

            Table t2 = GetTable(tokenizer.GetString(), channel);

            int[] col2 = ProcessColumnList(tokenizer, t2);

            if (table.GetIndexForColumns(col) == null)
            {
                CreateIndex(channel, table, col, "SYSTEM_FOREIGN_KEY_" + name, false);
            }

            if (t2.GetIndexForColumns(col2) == null)
            {
                CreateIndex(channel, t2, col2, "SYSTEM_REFERENCE_" + name, false);
            }

            table.AddConstraint(new Constraint(ConstraintType.ForeignKey, t2, table, col2, col));
            t2.AddConstraint(new Constraint(ConstraintType.Main, t2, table, col2, col));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructor using Main and Reference Table.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="main"></param>
        /// <param name="child"></param>
        /// <param name="columnMain"></param>
        /// <param name="columnRef"></param>
        public Constraint(ConstraintType type, Table main, Table child, int[] columnMain, int[] columnRef)
        {
            _type = type;
            _mainTable = main;
            _refTable = child;
            _mainColumns = columnMain;
            _refColumns = columnRef;
            _len = columnMain.Length;

            if (TracingHelper.AssertEnabled)
            {
                TracingHelper.Assert(columnMain.Length == columnRef.Length);
            }

            _mainData = _mainTable.NewRow;
            _refData = _refTable.NewRow;
            _mainIndex = _mainTable.GetIndexForColumns(columnMain);
            _refIndex = _refTable.GetIndexForColumns(columnRef);
        }
Ejemplo n.º 4
0
        private void AddForeignKeyOn(Tokenizer tokenizer, Channel channel, string name, Table table)
        {
            int[] col = ProcessColumnList(tokenizer, table);

            tokenizer.GetThis("REFERENCES");

            Table t2 = GetTable(tokenizer.GetString(), channel);
            int[]   col2 = ProcessColumnList(tokenizer, t2);

            if (table.GetIndexForColumns(col) == null)
            {
                CreateIndex(channel, table, col, "SYSTEM_FOREIGN_KEY_" + name, false);
            }

            if (t2.GetIndexForColumns(col2) == null)
            {
                CreateIndex(channel, t2, col2, "SYSTEM_REFERENCE_" + name, false);
            }

            table.AddConstraint(new Constraint(ConstraintType.ForeignKey, t2, table, col2,	col));
            t2.AddConstraint(new Constraint(ConstraintType.Main, t2, table, col2, col));
        }