Overview
In this post, we will learn about DBMS relational data model concepts. We will go through different relational model terminologies – attribute, tuple, cardinality, relational schema, domain etc. Thus, we will see how different terms are considered while creating a relational data model for a database.
Getting Started
The database can be represented as a collection of relations by the Relational model.
Informally each relation resembles a table.
When a relation is thought of as a table of values, each row in the table represents a collection of related data values. These values can be considered as facts describing a real-world entity or relationship. If you want to know the meaning of the values in each row of the table then table name and column names are helpful.
For Example: The table is called STUDENT because each row represents facts about a particular student entity. The column names Name, Roll No… Etc specifies how to interpret to data values in each row, based on the column each value is in. All values in a column consist of the same data type.
Name | Roll No. | Address | Class |
Micheal | 21 | Pune | 3rd Grade |
Arif | 11 | Nasik | 9th Grade |
Relational Model Terminology
Now, we will see different terminologies frequently used in relational data model concepts. They are –
- Attribute – Each column in a table represents attribute. It defines a relation. For example – Name, Roll No., Address, class etc.
- Tuple – It is single row of table. For example –
Micheal | 21 | Pune | 3rd Grade |
- Column – It represents set of values for specific attributes. For example –
Address |
Pune |
Nasik |
- Relational Schema – It represents name of the relation with it’s attributes. For example, STUDENT(Name, Roll no., Address, class) is relational schema for STUDENT.
- Degree – The number of attributes in the relation is called degree. For example, STUDENT relation in our example has degree 4 because it has four attributes (Name, Roll No., Address and class).
- Cardinality – The number of rows in the table is called cardinality. i.e. The number of tuples in the table is called cardinality. Above table has cardinality 2.
- Relational Key – Each row in the relational key has one or more attributes which can identify the row uniquely.
- Attribute Domain – A domain D is a set of atomic values i.e. each value in D is indivisible as far as the relational model is concerned. A common method of specifying a domain is to specify a data type from which the data and values forming the domain are drawn.
For example: A domain called human names is the set of names of persons.
Telephone-nos: The set of 7 digit phone numbers valid within a particular area code.
Employee-age: The set of all possible ages of employees of a company, between 16-60 years old.
The above are logical definitions of domains. For each domain, a data type or format is also specified.
The data type for the domain Names is the set of all character strings that represent valid person names.
The data type for the domain Employee-age is an integer number between 16 and 60.
A domain is thus given a name, a data type and a format.
A Detailed Explanation
A relation schema R, denoted by R(A1, A2…An) is made up of a relation name R and a list of attributes A1,A2…An. Each attribute Ai is the name of a role played by some domain D in the relation schema R. D is called the domain of Ai and denoted by dom(Ai). To describe a relation we need a relational schema. We call the name of relation as R.
The number of attributes ‘n’ of its relational schema is called the degree of a relation. The attributes ‘n’ of relation schema is called the degree of a relation.
Example –
An example of a relation schema for a relation of degree 7, which describes Patients of a hospital, is:
Patient (pat-name, address, contact-pername, peraddress, bloodgroup, reason, date)
For the above relation schema, Patient is the name of the relation which has 7 attributes.
A relation (or relation instance) r of the relation schema R(A1, A2…An), also denoted by r(R), is a set of n-tuples r={t1,t2..tn}, where each n-tuple t, is an ordered list of an values, t =< V1, V2,…,Vn> where each value Vi, 1 <= I <=n, is an element of dom (Ai), or is a special NULL value.
For example: Figure below shows an example of a Patient relation, which specifies to the Patient schema specified above. Each tuple in the relation represents a particular Patient entry.
Name | Address | Blood Group | Date | Reason | Name of Contact | Address of Contact Person |
---|---|---|---|---|---|---|
Rajeev | Pune | O- | 11/12/2018 | Fever | Vikash | Pune |
Kamruddin | Chinchwad | A+ | 08/12/2018 | Cold | Yadnesh | Chinchwad |
Jaysri | Nigdi | AB+ | 05/12/2018 | Diabetes | Shekhar | Akurdi |
– | – | – | – | – | – | – |
The relation is displayed as a table, where each tuple is shown as a row and each attribute corresponds to a column header including the interpretation of the values in that column.
NULL values represent attributes whose values are unknown or don’t exist for some individual Patient tuples.
Properties of Relation –
- Each attribute have a unique name.
- Tuple has unique value
- Name of the relation is distinct from all other relations.
- Each relation cell contains exactly one atomic (single) value.
Thus, we saw each terminologies used while talking about DBMS relational data model concepts.