Class Table
Represents a database table, which is a specialized ColumnSet containing columns, constraints, and relationships to other tables.
public class Table : ColumnSet, IVisitorAcceptor, ICheckable
- Inheritance
-
Table
- Implements
- Inherited Members
- Extension Methods
Remarks
The Table class extends the ColumnSet class to provide additional functionality specific to database tables, such as primary key generation, foreign key constraints, and referencing tables.
Constructors
Table(Database, string, string)
Represents a database table, which is a specialized ColumnSet containing columns, constraints, and relationships to other tables.
public Table(Database db, string name, string owner)
Parameters
dbDatabaseThe database that owns the table.
namestringThe name of the table.
ownerstringThe owner of the table.
Remarks
The Table class extends the ColumnSet class to provide additional functionality specific to database tables, such as primary key generation, foreign key constraints, and referencing tables.
Properties
Database
The database that owns the table.
public Database Database { get; }
Property Value
ForeignKeys
The foreign keys of the table.
public ForeignKeyCollection ForeignKeys { get; }
Property Value
FullName
Gets the fully qualified name of the schema item, which may include the owner or other contextual information, depending on the implementation of the derived class.
public override string FullName { get; }
Property Value
HasForeignKey
Indicates whether the table has a foreign key.
public bool HasForeignKey { get; }
Property Value
HasIndex
Indicates whether the table has an index.
public bool HasIndex { get; }
Property Value
HasPrimaryKey
Indicates whether the table has a primary key.
public bool HasPrimaryKey { get; }
Property Value
Indexes
The indexes of the table.
public IndexCollection Indexes { get; }
Property Value
NonFKColumns
Gets the columns of the table that are not foreign key columns.
public ColumnCollection NonFKColumns { get; }
Property Value
NonKeyColumns
Gets the columns of the table that are neither primary key nor foreign key columns.
public ColumnCollection NonKeyColumns { get; }
Property Value
NonPKColumns
Gets the columns of the table that are not primary key columns.
public ColumnCollection NonPKColumns { get; }
Property Value
Owner
The owner of the table.
public string Owner { get; }
Property Value
PrimaryKey
The primary key of the table.
public PrimaryKey PrimaryKey { get; }
Property Value
ReferencedTables
Gets a collection of tables that are referenced by foreign keys in this table.
public TableCollection ReferencedTables { get; }
Property Value
ReferencingTables
Gets a collection of tables that are referencing this table through foreign keys.
public TableCollection ReferencingTables { get; }
Property Value
Methods
AcceptVisitor(IVisitor)
Accepts a visitor, allowing it to perform operations on the implementing class. The visitor will typically have specific methods for handling different types of elements in the object structure.
public override void AcceptVisitor(IVisitor visitor)
Parameters
visitorIVisitorThe visitor instance that will perform operations on the implementing class.
GeneratePrimaryKey(string, IEnumerable<string>)
Creates a primary key for the table using the specified name and column names.
public void GeneratePrimaryKey(string name, IEnumerable<string> columnNames)
Parameters
namestringThe name of the primary key to be created.
columnNamesIEnumerable<string>A collection of column names that will be included in the primary key.
GetReferencingKey(Table)
Retrieves the foreign key in the current table that references the specified table.
public ForeignKey GetReferencingKey(Table table)
Parameters
tableTableThe table being referenced by the foreign key.
Returns
- ForeignKey
The foreign key that references the specified table, or null if no such key exists.
IsAssociationTable()
Determines whether the table is an association table. An association table is identified as having more than one referenced table, and all its columns are either foreign key columns or generated columns.
public bool IsAssociationTable()
Returns
- bool
True if the table is an association table; otherwise, false.