Introduction to Relationship in DBMS
DBMS, or Database Management Systems, is the process through which a Database is managed or controlled.
The correct explanation would require a bit more depth. Let’s start with what exactly is a database. A database is a collection of data. It may be in the form of tables, columns, charts, texts etc. Now, there can be may such databases piled together to form a single database. The manner in which these databases are acted upon gives us, what we call the Database management systems or DBMS. A database may have data of all forms, as suggested previously. The different steps that are taken to retrieve the data as well as store it, keeping in mind strict security concerns, is the ideal definition of a DBMS. Database Management Systems come in a myriad form. However, for this article, our focus is on the different Relationship in DBMS
A basic Entity Relationship Diagram
What are Relationships?
A relationship in a DBMS, is primarily the way two or more data sets are linked. This is so true for Relational Database Management Systems. One dataset may be then termed as the Foreign key and the ones linked to it may be termed as the Primary Key. There may be multiple Foreign and Primary keys linked to each other.
Relationships allow the datasets to share and store the data in separate tables. They also help link disparate data with each other.
Relationships are of three types and the next segment talks about the same.
Types of Relationship in DBMS
There are three types of relationships that can be found in DBMS:
- One to One
- One to Many
- Many to Many
Let us see what each one of them entails.
1. One to One
This relationship tells us that a single record in Table A is related to a single record in Table B. And vice versa. Now, the moot question that may arise here is, that why not move both the data into a single table. There may be many reasons for it. One primary reason usually is security.
Let us look into an example: We have to create a table where details of our name, age, email, address, telephone number and password needs to be stored. Now, all of this are sensitive information and we would not want to have them bundled together in a single table.Hence, to create a greater security around it, we create a separate table for the password with different access control, so that only a selected few will have access to it.
2. One to Many
This type of relationship in a Database Management System (DBMS) is the most common type of relationship. This entails one data in Table A to have links to multiple data in Table B. However, a single data in Table B, will have link to a single data in Table A. One good example to showcase such a relationship is through a bank account. One individual may have multiple bank accounts, but each bank account will be linked to one specific owner or account holder only (provided we are not talking about a joint bank account)
3. Many to Many
Consider two table A and B. Each data in Table A is linked to all the data in Table B and vice versa. A great example would be linking a student table to the courses table. Table A has the name of all the students while Table B has the name of all the courses. A particular student may enrol oneself to more than one course whilst a course may have more than one student. Hence, it becomes a many to many relationships.
Now, the market is replete with Database management systems like MySql, Microsoft Access, SQL Server, Oracle. Because of the glut of so many of them, it becomes imperative that they have to be in communication with each other. Hence, most Database Management Systems come in with something called an Open Database Connectivity (ODBC) driver. What this does is allows a particular database to integrate with the other database and sync the flow of information. A food example would be the SQL statements: SELECT which queries to select the said data and INSERT which queries to push the selected data into a particular table.
What is the importance of Relationship in DBMS
- A relationship in DBMS is an integral cog in the wheel. It helps to streamline the entire workflow, through the database can provide a relevant output. Let us look at some of the advantages of having relationships in a Database Management System (DBMS).
- Redundancy of data is minimised because of relationships. While creating relationships, finer changes will be made to the table structure. Hence, as and when more data is added, a level of perfection will be achieved. This leads to a final table structure which is near perfect and devoid of irrelevant information.
- Relationships also help in establishing a smooth workflow. Many a times there will be queries which will force the command to pull data from disparate tables. In the absence of a relationship such a venture will fail and the query will return a null.
- A well-defined relationship adds more integrity to the table structure and makes the Database Management System more efficient. This leads to better decision making. Another advantage that comes to mind is the flexibility it provides to users while querying for data. Complex queries are easily pulled off. The more maturity the database undergoes, the greater is the probability of perfection. Collaboration also becomes easy amongst multiple users.
The relationship in a Database Management System (DBMS) is the most essential part of its functioning. Without proper relationships the entire database structure would become useless. We also need to keep in mind that though it is essential to create relationships which may look to be complex at times, it has to thought after and well defined for a favourable outcome.
This is a guide to Relationship in DBMS. Here we discuss the introduction to Relationship in DBMS, with flowchart, types with explanaion and importance. You can also go through our other related articles to learn more –