A relational database is a storage mechanism based on the relational model of Computer Scientist Edgar Codd. It stores, retrieves and allows functional implementation of data in a fashion that they are interrelated. Data is stored as tables in a relational database.
Tables are a combination of rows and columns where data is represented following a relational model and can store thousands or sometimes, millions of data.
Data is stored as an instance in a row called a record. Each Row is unique and has a unique identifier called the key.
Each column has a descriptive name called attributes and contains data of a certain datatype.
In the above example, there are three rows or records.
Each record has a unique identifier called ID and each column stores a different datatype.
The first and third column stores integer, the second column stores string, and the fourth column stores date.
SQL or Structured Query Language is a programming language used to communicate with a relational database. Furthermore, SQL syntax is similar to the English language making it easy to learn.
SQL has several benefits which make all the major RDBMS choose it as their database language. With SQL users mainly perform CRUD operations like:
SQL commands are categorized into three groups:
A relational database management system (RDBMS) is the software that is used to record, manipulate, and retrieve data securely and reliably from connected data points.
The basic function of a RDBMS is the CRUD (Create, Read, Update, Delete) function. Besides, there is also some advance usage of RDBMS:
An object requires to be flattened before storing in a relational database as a relational database stores data only as tables. Consequently, object schema needs to be correctly mapped with relational database schema to avoid Object Relational Impedance Mismatch.
In a relational database, behavior is implemented via stored procedures and/or functions that can be called both internally by the database and by external applications. The difference between stored functions and procedures that run within an RDBMS lies in what the operation can return and if it can be invoked in a query.
Concurrency Control is a collision resolution strategy when a concurrent query is being executed on the same record. For example, when two people try to book the same airline ticket the first one should be allocated the choice of his seat and the second one rejected.
Transactions are a collection of actions on a database like create, read, update records- which form a work unit. The transaction may be flat ie, they are rolled back if each and every action is not successfully completed or, they may be nested. In nested transactions, some of the sub-transaction can’t be rolled back.
Referential integrity is the maintenance of synchronicity between various data. If one data references another data then the second data must exist. If data is deleted then all the references to it also must be deleted to prevent false references.
A relational database is maintained through a relationship between two tables using a primary key/foreign key pair. The connection between the foreign and primary keys maintains a relationship throughout the entire database.
In a non-relational database, there are no tables, rows, or keys, instead a storage model suitable to the specific data requirement is used.
Data in a relational database is consistent in input and meaning whereas data in a non-relational database allows variants of input making it very dynamic.