Get free ebooK with 50 must do coding Question for Product Based Companies solved
Fill the details & get ebook over email
Thank You!
We have sent the Ebook on 50 Must Do Coding Questions for Product Based Companies Solved over your email. All the best!

Relational Model in DBMS

Last Updated on March 2, 2023 by Prepbytes

In this blog, we will learn about the relational model in DBMS, we will learn about the concepts used in the relational data model in DBMS, followed by constraints that we have to take care of while working with the relational model in DBMS, We will also see some anomalies that occur while dealing with the relational data model in DBMS, we will also see some operations of relational model in DBMS followed by advantages and disadvantages of storing the data in the relational model in DBMS.

What is Relational Model in DBMS?

The Relational Model in DBMS is a method of organizing data in a database using tables, also known as relations. Each table consists of a set of rows, known as tuples, and a set of columns, known as attributes. The data in each table is organized in a way that allows it to be easily related to data in other tables, allowing for efficient querying and data manipulation. The relational model is based on set theory and first-order predicate logic and uses a formal language known as relational algebra to define operations on the data. The relational model is the most widely used model for database management systems and is the foundation for most modern databases, such as MySQL, Oracle, and Microsoft SQL Server. The relational model also allows for the use of standard SQL (Structured Query Language) which is easy for developers to use and understand. The relational model is considered to be more flexible and powerful than other models, such as the hierarchical and network models.

A simple, effective, and adaptable method of storing and accessing structured data was made possible by the use of tables to store the data. This data model’s simplicity makes it simple to retrieve and sort the data. As a result, it is widely utilised for data processing and storage globally.

Consider an example where you are having a relation of student so the table name will be student and you will have the attributes of student like name, CGPA, roll_no,age.

Roll_no Name Age CGPA
1 Naman 21 9.2
2 Vikas 20 8.9
3 Harsh 21 8.5
4 Neeraj 20 8.3

In the above table we have the table name as a student as we are describing the relation of student on various factors like roll_no, age, name, and CGPA. All these distinguishing factors are the attributes related to the entity which are the rows. This is one example of the relational data model in DBMS.
There might be a question in your mind who proposed the relational model? The answer is Edgar F. Codd.

Concepts of Relational Model in DBMS

In this section, we will discuss the various terminologies available in the relational model in DBMS. The relational model in DBMS (Database Management Systems) is a method for organizing data using tables, also known as relations, which consist of rows and columns. Each row represents a single record, and each column represents a field within that record. The columns in a table are defined by a set of attributes, and each table has a unique key that can be used to identify and access specific rows.

The relational model is based on the mathematical concept of a relation, and it is used to model real-world entities and their relationships. The relational model is widely used in database management systems because it allows for the efficient manipulation and querying of data and it has a simple and intuitive structure.

  • Relation: A table in the relational model, consisting of rows and columns.
  • Tuple: A single row in a relation, representing a single record.
  • Attribute: A column in a relation, representing a field within a record.
  • Domain: The set of allowed values for a specific attribute.
  • Primary key: A unique identifier for each tuple in a relation, used to access and manipulate specific records.
  • Foreign key: A reference to a primary key in another relation, used to establish relationships between tables. key to represent the relationship between tables is called the Foreign Key.
  • Normalization: The process of organizing data in a relational database in dbms to minimize data redundancy and improve data integrity.
  • Join: A SQL operation that combines rows from two or more tables based on a related column between them.
  • Index: A data structure that improves the speed of data retrieval operations in a database by allowing for faster searching and sorting.
  • Attribute Domain: It is the set of predefined values that an attribute can acquire.
  • Cardinality: This will define the total number of rows or entities present in the relation.

By summarising we can say that A Relation is a group of columns and rows (tuples) (attributes). Tuples represent real-world entities in a connection, whereas attributes are the characteristics that specify the relationship. The relational schema describes the structure of the relationship. Relational keys are employed to distinguish one row from another in a table or to establish the connection between two tables.

Constraints in Relational Model in DBMS

In a relational database management system (DBMS), constraints are used to enforce rules on the data stored in the database. These constraints are used to maintain the integrity and consistency of the data. There are several types of constraints that can be applied in a relational model, including

  • Primary key constraint: This constraint ensures that each row in a table has a unique identifier. It is used to identify each row in the table and is typically used as the primary index for the table.
  • Foreign key constraint: This constraint is used to establish a link between two tables. It ensures that a value in one table corresponds to a value in another table, and is typically used to enforce referential integrity.
  • Domain Constraint: A domain constraint is a constraint that defines the set of valid values for a particular attribute or column in a database table. It is used to ensure that the values stored in a column are of a specific data type and meet certain requirements, such as being within a certain range or matching a specific pattern. For example, a domain constraint can be used to ensure that a column containing email addresses only contains valid email addresses.
  • Integrity Constraint: Integrity constraint is a set of rules that are enforced by the database management system to ensure the consistency and accuracy of the data in a database. Integrity constraints are used to ensure that the data stored in the database meets certain conditions and that relationships between tables are maintained. There are several types of integrity constraints, including primary key, foreign key, not null, check, and unique constraints. These constraints are used to ensure that the data in the database is accurate and reliable and that it meets the requirements of the business or application. Integrity constraint is a broader term that can include Domain constraint as well as other types of constraints like referential integrity, entity integrity, domain integrity, and semantic integrity, etc.
  • Not null constraint: This constraint ensures that a column in a table cannot contain a null value. This is used to ensure that all rows in a table have a value for a specific column.
  • Check constraint: This constraint is used to ensure that the values in a column meet a certain condition. For example, it can be used to ensure that a value is within a certain range or that it matches a specific pattern.
  • Unique constraint: This constraint ensures that the values in a column are unique across all rows in the table. This is used to ensure that no duplicate values are stored in the table.

All of these constraints are important for maintaining the integrity and consistency of the data in a relational database in dbms. They help to ensure that the data is accurate and reliable, and they also help to prevent errors and inconsistencies from creeping into the data.

One important thing to keep in mind is that all these constraints can be added to the schema of the database and enforced by the DBMS itself during the data insertions, updates and deletions. And it is also possible to disable or drop the constraints if needed. These were the various constraints in the relational model in DBMS.

Anomalies in the Relational Model in DBMS

Here we will discuss the various anomalies present in the relational model in DBMS. Anomalies in the relational model in DBMS are nothing but the inconsistencies or issues that can occur while working with the relational model in DBMS.

  • Insertion anomaly: This occurs when it is not possible to insert new data into the database without violating the integrity constraints. For example, consider a database that stores information about students and their courses. If there is no course record for a student, then it will be impossible to insert the student’s information into the database.
  • Update anomaly: This occurs when updating data in the database can result in data inconsistencies, such as updating one piece of data and leaving related data out of date. For example, consider a database that stores information about employees and their departments. If an employee’s department is changed, but the department name is not updated in the employee’s record, then the data will be inconsistent.
  • Deletion anomaly: This occurs when deleting data from the database can result in the loss of important information, such as deleting a parent record and also deleting all the child records. For example, consider a database that stores information about orders and their line items. If an order is deleted, all the information about the line items associated with that order will also be deleted, even though it may be important to keep that information.

These anomalies are the main reasons why database normalization techniques are used to design a database in order to eliminate data redundancy and inconsistencies.

Properties of Relational Model in DBMS

There are certain properties that one needs to follow while working on a relational model in DBMS.

  • Each attribute must have a distinct name
  • Each cell must contain a single value.
  • The tuple must not have any duplicate value.
  • The order of the sequence of the tuple can vary.
  • Name of the particular relation must be different from other relations.

Advantages of Relational Model in DBMS

Here we will see some of the advantages of the relational model in DBMS.

  • Easy to understand and use: The relational model is based on mathematical concepts and is easy to understand and use.
  • Flexibility: The relational model allows for easy modification of the database structure without affecting the existing data.
  • Data Integrity: The relational model enforces data integrity rules to ensure that the data is accurate and consistent.
  • Data Independence: The relational model allows for data independence, which means that changes to the logical structure of the data do not affect the application that accesses the data.
  • Scalability: Relational database in dbms can handle large amounts of data and can be easily scaled to meet growing needs.

Disadvantages of the Relational Model in DBMS

In this section, we will discuss the disadvantages of using a relational model in DBMS.

  • Complexity: The relational model can be complex to implement, especially for large and complex databases.
  • Limited scalability: Relational databases can be limited in their scalability, especially when dealing with very large amounts of data.
  • Limited support for unstructured data: Relational database in DBMS are not well-suited for storing unstructured data such as images and videos.
  • Limited support for complex data relationships: Relational databases can have difficulty handling complex data relationships, such as many-to-many relationships.
  • Performance degradation: The relational model can experience performance degradation as the database size increases and the number of concurrent users increases.

Conclusion
In this article, we have discussed the relational model in DBMS, followed by a proper explanation of the same with constraints in the relational model in DBMS, constraints and the problems or issues which are known as anomalies that occur while working with the relational model in DBMS, We have also discussed the properties of the relational model in DBMS, at last, we have discussed the advantages and disadvantages of relational model in DBMS, so the user can decide accordingly how to use the relational model in DBMS.

Leave a Reply

Your email address will not be published. Required fields are marked *