DBMS_Module-2_Notes
DBMS_Module-2_Notes
Relational Model
Introduction to Relational Model
The Relational Model is a fundamental concept in Database Management Systems (DBMS) that
organizes data into tables, also known as relations. This model simplifies data storage, retrieval,
and management by using rows and columns.
• Data is stored in tables having relationships between them called the Relational model.
• The relational model supports the operations like Data definition, Data manipulation, and
Transaction management.
• Each column has a distinct name and they are representing attributes.
• Each row represents a single entity.
Relational model constraints are rules applied to a relational database to maintain data integrity,
consistency, and accuracy by restricting the values that can be stored in relations (tables).
❑ Domain Constraint – Ensures that values in an attribute belong to a specific domain (data
type, range, or format).
Example : If we assign the datatype of attribute SRN as int, we can’t give it values other than
int datatype.
Example: The EID column is a Primary Key, ensuring each entry is unique and not null.
❑ Entity Integrity Constraint – The Entity Integrity Constraint ensures that each table
(relation) must have a Primary Key, and that Primary Key values cannot be NULL.
Example: The given table demonstrates the Entity Integrity Constraint, which ensures
that every table has a Primary Key, and that key cannot have NULL values.
Here, the EID column serves as the Primary Key, uniquely identifying each row while
ensuring that no record has a NULL or duplicate EID, maintaining the integrity of the entity.
❑ Referential Integrity Constraint – It ensures a Foreign Key refers to a valid Primary Key in
another table.
Example: The given tables demonstrate the Referential Integrity Constraint, which
ensures that a foreign key in one table refers to a valid primary key in another table.
Here, the Dno (Department Number) in the Employee table is a Foreign Key, which
references the Dno (Primary Key) in the Department table. This ensures that an
employee's department exists in the Department table
Table STUDENT
Key Terms
• Attribute: Attributes are the properties that define an entity. e.g. ROLL_N0(1,2,3,4)
• Relation Schema: A relation schema defines the structure of the relation and represents
the name of the relation with its attributes. e.g. STUDENT (ROLL_NO, NAME, ADDRESS,
PHONE, and AGE) is the relation schema for STUDENT. If a schema has more than 1
relation it is called Relational Schema.
• Tuple: Each row in the relation is known as a tuple. The above relation contains 4 tuples.
• Relation Instance: The set of tuples of a relation at a particular instance of time is called
a relation instance. It can change whenever there is an insertion, deletion or update in the
database.
• Degree: The number of attributes in the relation is known as the degree of the relation. The
STUDENT relation defined above has degree 5.
• NULL Values: The value which is not known or unavailable is called a NULL value. It is
represented by NULL. e.g. PHONE of STUDENT having ROLL_NO 4 is NULL.
• Primary Key: It is used to uniquely identify the records. It is a combination of not null and
unique. One table should have only one primary key. The STUDENT table has ROLL_NO
as primary key.
Department(D_id, Dname)
STUDENT
S_id Sname DOB Phone D_id C_id
DEPARTMENT
D_id Dname
Courses
C_id Cname F_id
Faculty
F_id Fname D_id
Update Operations
• Insert Operation:- The INSERT operation is used to insert new records in a table.
Syntax:
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
Example:
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME) VALUES (105, 'Emma’, 'Watson’);
INSERT INTO EMPLOYEE VALUES (106, 'John', 'Doe', 55000), (107, ‘Tina', ‘Roy', 50000);
• Delete Operation:- The DELETE operation is used to delete existing records in a table.
Syntax:
Example:
• Update Operation:- The UPDATE statement is used to modify the existing records in a
table.
Syntax:
UPDATE table_name
WHERE condition;
Example: