Unit 3
Unit 3
• Relational Model was proposed by E.F. Codd to model data in the form of relations or tables.
• After designing the conceptual model of Database using ER diagram, we need to convert the conceptual
model in the relational model which can be implemented using any RDBMS languages like Oracle,SQL,
MySQL etc. So we will see what Relational Model is.
1. Relation – In the Table model the, tables are saved in the relation format. It is stored along with its
entities. A reation has two properties rows and columns. Rows represent records and columns represent
attributes.
2. Tuple – It is nothing but a single row of a table, which contains a single record.
3. Attribute: Each column in a Table. Attributes are the properties which define a relation. e.g.,
Student_Rollno, NAME,etc.
4. Cardinality: Total number of rows present in the Table.
5. Degree: The total number of attributes which in the relation is called the degree of the relation.
6. Domain: A domain is a set of allowable values for one or more attributes.
• Integrity constraints are used to ensure accuracy and consistency of the data in a relational
database.
• Integrity constraints are set of rules that the database is not permitted to violate.
• Constraints may apply to each attribute or they may apply to relationships between tables.
• Integrity constraints ensure that changes (update, deletion, insertion) made to the database by
authorized users do not result in a loss of data consistency.
• Thus, integrity constraints guard against accidental damage to the database.
• Example - A blood group must be 'A' or 'B' or 'AB' or '0' only (can not any other values else).
❖ Domain Constraint
❖ Entity Integrity Constraint
❖ Referential Integrity Constraint
❖ Key Constraints
1. Domain Constraints
Domain constraints de-fines the domain or the valid set of values for an
attribute.
The basic rules for converting the ER diagrams into relational model are,
1) Convert all the entities in the diagram to tables –
All the entities represented in the rectangular box in the ER diagram become separate tables in the
database. In the above diagram, STUDENT is an entity convert into a separate table.
Table -- STUDENT
Table – STUDENT
3) Key attribute in the ER diagram becomes the primary key of the table –
In above diagram, ROLLNO is the key attribute of the STUDENT entity. Hence we consider it as the
primary key of STUDENT table.
Table – STUDENT
Table – STUDENT
5) Any multi-valued attributes are converted into new table –
A MOBILE_NO of the STUDENT entity is a multivalued attribute. Any student can have any number
of mobile numbers.
So, we cannot represent multiple values in a single column of STUDENT table. Hence we create a
separate table CONTACT with ROLLNO and MOBILE_NO as its columns.
Table – STUDENT
ROLLNO MOBILE_NO
Table – CONTACT
Table–STUDENT
3.5 The Relational Algebra
✓ Select
✓ Project
✓ Union
✓ Set different
✓ Intersection
✓ Cartesian Produt
✓ Natural Join
*Exmple: 01
*Exmple: 02
*Exmple: 03
*Exmple: 04
*Exmples:
*Example: 01
*Example: 02
*Example: 03
*Example: 04
*Example:
*Example:
*Example:
*Example:
*Example: