What is a table? Table and Query
What is a table? Discuss different parts of a table. Table is the most important object of a database. It is the central concept in relational databases.
All data in a relational database is stored in tables. Table is known as relation. Following is an example of a table.
Figure 6.1: An example of Table
Parts of a Table
A table consists of the following parts:
- Field or Attribute
- Record or Row
1. Field or Attribute
A field is a combination of related characters. A field is known as attribute in relational database. An attribute is a named column of a relation. Each field in a table has unique name and predefined data type. Each field may contain certain default value. Following are three examples of fields:
Figure 6.2: Three fields
2. Record or Row
A record is a collection of related field. A record is known as tuple in relational database. Record is also called row. In the above figure, the information of each student is stored in a separate row. Each record in the table stores data about different object. Following are two examples of records in a table:
Figure 6.3: Two rows of a Relation
Discuss different characteristics of a table/relation. Also define degree and cardinality of a relation.
Characteristics of Tables
The tables of a relational database have the following characteristics:
- Each field of the table contains only one value.
- Each column has a distinct name. It is the name of the attribute or field it represents.
- The order of the columns is immaterial.
- Each row represents a record.
- Each row is distinct. There are no duplicate rows.
- The order of rows is immaterial.
The data of each entity is stored in a separate table. It means that the data is stored only once. It makes the database more efficient. It also reduces data entry errors.
Degree of a relation
The number of fields or attributes in a relation is called the degree of a relation. The degree of a relation is usually not changed once the table has been created. A relation with five fields has a degree of 5.