Characteristics of Tables
Recall that the earlier discussion of entities introduced the concept of an example of an entity. In SQL Server the tables are used to store information about each instance of an entity.
Note that a table stores each instance of an entity as a row in the table by each attribute stored in a column. Columns and Rows are sometimes referred to as records and fields, correspondingly. The order of the rows and columns in a table is not important, while columns which store related information should be grouped together. Note that in the instance table, the FirstName and LastName columns are grouped in this way.
The following list review the terminology just mentioned below:
• Entities are modeled as tables.
• In a table, each instance of an entity is known as a row
• In a table attributes are modeled as columns
• Programmers frequently refer to rows and columns as records and fields, correspondingly
While you can choose any names you require for tables and columns subsequent a few guidelines can make your data model consistent and easier to read. These guidelines involve:
• Table and column names are commonly singular; this is a relational modeling convention.
• Tables are approximately always named after the entity they represent
• Varied case is preferable to using underscores to separate words.
• Ensure that columns which store the similar type of information in variant tables have the similar name. For example, if the teacher table and the student table both store address information and make sure in which the column storing the ZIP code has the similar name in both tables.
• Ensure that same named columns all have the similar data types.
SQL Server does place some restrictions on table and column names. The restrictions involved the following:
- Column and Table names cannot be longer than 128 characters.
- Within the database Table names must be unique
- Within a table Column names must be unique
SQL Server enforces the uniqueness of table and column names for you but for a relational model to work properly and each row must also be unique. This concept is known as row integrity or entity integrity. Alternatively, each instance of an entity must be distinguishable from all other instances. The SQL Server does not automatically enforce it and the person designing the database must establish this row uniqueness into the data model. Row uniqueness is enforced through using a special column in the table known as the primary key.