A Quick Guide to Relational Model in DBMS

Introduction

In this article, we will discuss the relational model in DBMS. We will discuss what it is, the constraints in the relational model, and also the concepts of the relational model in DBMS. A database management system (DBMS) uses an abstract model called the relational model to organize and manage the data it stores. It stores data in relations, two-dimensional interrelated tables where each row denotes an entity and each column denotes the entity's properties. Let us understand what the relational model in DBMS is.

Relation Model: What is It?

A method for managing and logically representing the data kept in a database is the relational model for database management. The data in this model is arranged into a set of two-dimensional, related tables, also referred to as relations. Each relation is made up of rows and columns, where the columns correspond to the records and the columns to the attributes of an entity.

Tables were used to store the data, making it simple, effective, and adaptable to store and access structured data. This data model's simplicity allows for simple data access and sorting. As a result, it is widely utilized globally for data processing and storage. Let us understand some important concepts in the relational model.

Important Concepts

The relational model is the foundation of a relational database, as was previously discussed. Based on the relational paradigm, this database is made up of numerous parts. These comprise:

  • Relation: A two-dimensional table that is used to hold a group of data pieces.
  • Tuple: Row of the relation, representing an actual thing.
  • Attribute or Field: The relation's column displays the properties that make up the relationship.
  • Attribute Domain: The set of predefined atomic values that an attribute can take, or the "attribute domain," outlines the permitted values for an attribute.
  • Degree: The total number of attributes contained in the relation is the attribute count.
  • Cardinality: A relation's cardinality, or the total number of rows it contains, indicates the number of entities that are engaged in the relationship.
  • The relational schema, which explains the structure and design of the relation, is its logical blueprint. The name of the table, along with the attributes' kinds, are all included:

TABLENAME(ATTRIBUTE1 TYPE1, ATTRIBUTE2 TYPE2, ...)

  • The group of records that make up a relation at any one time is known as a relational instance.
  • Relation Key: It's an attribute or set of characteristics that can be used to distinguish one entity from another in a table or to establish the connection between two tables. There are six main kinds of relation keys:
  1. Primary Key
  2. Alternate Key
  3. Foreign Key
  4. Candidate Key
  5. Super Key
  6. Composite Key

Let us understand what the constraints in the relational model in DBMS are.

Constraints

Relational models employ a few criteria to make sure the data is accurate and easily accessible. Relational Integrity Constraints are the name for these guidelines or limitations. Before executing any action, such as insertion, deletion, or updating on the data existing in a relational database, these restrictions are examined. These limitations include the following:

  • According to the domain constraint, every property must have a value that falls inside a given range of values. The Attribute Domain idea is used to implement it.
  • According to key constraints, every relation must include an attribute, or combination of attributes, called the Primary Key, that may be used to uniquely identify a tuple within that relation. NULL and the same value for two separate tuples are not permitted for this key.
  • According to the referential integrity constraint, the restriction is established between two related tables. It states that a key attribute of a different or identical table must exist in the given relation if the relation in question refers to it.

Let us understand what the anomalies are in the relational model.

Anomalies

The excessive redundancy in the data stored in the database may cause any unexpected behavior we observe while working with relational databases. This may result in a variety of anomalies in the DBMS, including:

  • Insertion anomalies are instances where there is insufficient data in the database, making it impossible to insert data. Consider this scenario: The GroupNumber attribute is set up, so null values are not permitted, and we are grouping the entire class for a project. The database can only store a new student admitted to the class but is immediately placed in a group.
  • Deletion anomalies are when data is accidentally lost from the database due to the deletion of another data element. Let's take an employee relationship as an example, which would have the person's information and the department they work in. The data about the department will also be lost if a department only has one employee and we remove this individual's information from the table. Data discrepancy may result from this.
  • Data inconsistency resulting from data redundancy and incomplete database updates is known as a modification/update anomaly. Consider this: Imagine if duplicate entries were added to the database while it was being updated. The database will now contain inconsistent data if the user is unaware that the data is stored redundantly after updating.

All of these anomalies may cause the user to experience unpleasant behavior. With the aid of a normalization procedure, these anomalies can be eliminated.

Conclusion

The relational model in DBMS is a method for managing and logically representing the data kept in a database by placing the data in tables. Some significant elements of the Relational Model include Relations, Attributes and Tuples, Degree and Cardinality, Relational Schema and Relation instance, and Relation Keys.

In the relational model, restrictions like domain, key, and referential integrity are implemented to maintain data integrity. In a relational database, redundancy in the data can cause insertion, deletion, and updating anomalies.