Anomalies & Constraint in Relational Model | Database Management System (DBMS) - Computer Science Engineering (CSE) PDF Download

Relational Model in DBMS

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.

What is Relational Model?
Relational Model represents how data is stored in Relational Databases.  A relational database stores data in the form of relations (tables). Consider a relation STUDENT with attributes ROLL_NO, NAME, ADDRESS, PHONE and AGE shown in Table 1. 

STUDENT 

Anomalies & Constraint in Relational Model | Database Management System (DBMS) - Computer Science Engineering (CSE)

Important Terminologies

  • Attribute: Attributes are the properties that define a relation. e.g.; ROLL_NO, NAME
  • Relation Schema: A relation schema represents name of the relation with its attributes. e.g.; STUDENT (ROLL_NO, NAME, ADDRESS, PHONE and AGE) is 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 tuple. The above relation contains 4 tuples, one of which is shown as:

Anomalies & Constraint in Relational Model | Database Management System (DBMS) - Computer Science Engineering (CSE)

  • Relation Instance: The set of tuples of a relation at a particular instance of time is called as relation instance. Table 1 shows the relation instance of STUDENT at a particular time. It can change whenever there is insertion, deletion or updation in the database.
  • Degree: The number of attributes in the relation is known as degree of the relation. The STUDENT relation defined above has degree 5.
  • Cardinality: The number of tuples in a relation is known as cardinality. The STUDENT relation defined above has cardinality 4.
  • Column: Column represents the set of values for a particular attribute. The column ROLL_NO is extracted from relation STUDENT.

Anomalies & Constraint in Relational Model | Database Management System (DBMS) - Computer Science Engineering (CSE)

  • NULL Values: The value which is not known or unavailable is called NULL value. It is represented by blank space. e.g. PHONE of STUDENT having ROLL_NO 4 is NULL. 

Constraints in Relational Model

While designing Relational Model, we define some conditions which must hold for data present in database are called Constraints. These constraints are checked before performing any operation (insertion, deletion and updation) in database. If there is a violation in any of constrains, operation will fail. 

Domain Constraints: These are attribute level constraints. An attribute can only take values which lie inside the domain range. e.g,; If a constrains AGE>0 is applied on STUDENT relation, inserting negative value of AGE will result in failure. 

Key Integrity: Every relation in the database should have atleast one set of attributes which defines a tuple uniquely. Those set of attributes is called key. e.g.; ROLL_NO in STUDENT is a key. No two students can have same roll number. So a key has two properties: 

  • It should be unique for all tuples.
  • It can’t have NULL values.

Referential Integrity: When one attribute of a relation can only take values from other attribute of same relation or any other relation, it is called referential integrity.
Let us suppose we have 2 relations:
1. STUDENT 

Anomalies & Constraint in Relational Model | Database Management System (DBMS) - Computer Science Engineering (CSE)

2. BRANCH 

Anomalies & Constraint in Relational Model | Database Management System (DBMS) - Computer Science Engineering (CSE)


BRANCH_CODE of STUDENT can only take the values which are present in
BRANCH_CODE of BRANCH which is called referential integrity constraint. The relation which is referencing to other relation is called REFERENCING RELATION (STUDENT in this case) and the relation to which other relations refer is called REFERENCED RELATION (BRANCH in this case). 

Anomalies

An anomaly is an irregularity, or something which deviates from the expected or normal state. When designing databases, we identify three types of anomalies: Insert, Update and Delete. 

  1. Insertion Anomaly in Referencing Relation: We can’t insert a row in REFERENCING RELATION if referencing attribute’s value is not present in referenced attribute value. e.g.; Insertion of a student with BRANCH_CODE ‘ME’ in STUDENT relation will result in error because ‘ME’ is not present in BRANCH_CODE of BRANCH. 
  2. Deletion/ Updation Anomaly in Referenced Relation: We can’t delete or update a row from REFERENCED RELATION if value of REFERENCED ATTRIBUTE is used in value of REFERENCING ATTRIBUTE. e.g; if we try to delete tuple from BRANCH having BRANCH_CODE ‘CS’, it will result in error because ‘CS’ is referenced by BRANCH_CODE of STUDENT, but if we try to delete the row from BRANCH with BRANCH_CODE CV, it will be deleted as the value is not been used by referencing relation.
    It can be handled by following method: 
    (i) ON DELETE CASCADE: It will delete the tuples from REFERENCING RELATION if  value used by REFERENCING ATTRIBUTE is deleted from REFERENCED RELATION. e.g;, if we delete a row from BRANCH with BRANCH_CODE ‘CS’, the rows in STUDENT relation with BRANCH_CODE CS (ROLL_NO 1 and 2 in this case) will be deleted.
    (ii) ON UPDATE CASCADE: It will update the REFERENCING ATTRIBUTE in REFERENCING RELATION if attribute value used by REFERENCING ATTRIBUTE is updated in REFERENCED RELATION. e.g;, if we update a row from BRANCH with BRANCH_CODE ‘CS’ to ‘CSE’, the rows in STUDENT relation with BRANCH_CODE CS (ROLL_NO 1 and 2 in this case) will be updated with BRANCH_CODE ‘CSE’. 

Super Keys
Any set of attributes that allows us to identify unique rows (tuples) in a given relation are known as super keys. Out of these super keys we can always choose a proper subset among these which can be used as a primary key. Such keys are known as Candidate keys. If there is a combination of two or more attributes which is being used as the primary key then we call it as a Composite key.

The document Anomalies & Constraint in Relational Model | Database Management System (DBMS) - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Database Management System (DBMS).
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
62 videos|66 docs|35 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Anomalies & Constraint in Relational Model - Database Management System (DBMS) - Computer Science Engineering (CSE)

1. What is the relational model in DBMS?
Ans. The relational model in DBMS is a conceptual framework that represents data in the form of tables with rows and columns. It organizes data into relations, where each relation represents a table and each row represents a record or tuple, and each column represents an attribute or field. The relational model is widely used in database management systems for its simplicity and flexibility.
2. What are constraints in the relational model?
Ans. Constraints in the relational model are rules or conditions that are applied to the data to maintain data integrity and consistency. These constraints define the valid data values and relationships between tables. Some common types of constraints include primary key constraints, foreign key constraints, unique constraints, and check constraints.
3. What are anomalies in the relational model?
Ans. Anomalies in the relational model refer to the inconsistencies or errors that can occur in the database when performing operations such as insert, update, or delete. There are three types of anomalies: insertion anomaly, deletion anomaly, and update anomaly. These anomalies can lead to data inconsistency and affect the overall integrity of the database.
4. How do constraints help in the relational model?
Ans. Constraints play a crucial role in maintaining data integrity and consistency in the relational model. They ensure that only valid data is inserted or updated in the database, preventing any inconsistencies or errors. Constraints also help in enforcing data relationships between tables, such as referential integrity using foreign key constraints. By defining constraints, the database management system can automatically enforce the rules and maintain the quality of the data.
5. What are some frequently used constraints in the relational model?
Ans. Some frequently used constraints in the relational model include: - Primary key constraint: Ensures that each row in a table has a unique identifier. - Foreign key constraint: Defines a relationship between two tables, ensuring referential integrity. - Unique constraint: Ensures that the values in a column or a combination of columns are unique. - Check constraint: Defines a condition that must be satisfied for a column or a combination of columns. - Not-null constraint: Ensures that a column cannot have a null value.
62 videos|66 docs|35 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Extra Questions

,

Previous Year Questions with Solutions

,

Anomalies & Constraint in Relational Model | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

shortcuts and tricks

,

Important questions

,

past year papers

,

ppt

,

Summary

,

Anomalies & Constraint in Relational Model | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

Objective type Questions

,

Exam

,

Sample Paper

,

practice quizzes

,

study material

,

Anomalies & Constraint in Relational Model | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

Viva Questions

,

mock tests for examination

,

pdf

,

MCQs

,

video lectures

,

Semester Notes

,

Free

;