Relational Databases
Characteristics of RDBMS
Table :
Data is stored in a table and consists of rows and columns. Each row represents the single instance of an entity. Columns defines the properties of an entity. Each column is defined by a datatype. All the rows have same number of columns.
Some columns are used to establish relationship between tables.
Primary key uniquely identifies each row. Only one primary key is allowed to use in a table. The primary key does not accept the any duplicate and NULL values.
Foreign key is used reference or link to the primary key of another table.
Splitting an entity into more than one table refers to normalization which helps in reducing storage, avoids data duplication, improves data quality.
Use cases of RDBMS :
Use cases of RDBMS :
- Well suited for OLTP applications.
- Examples of OLTP applications - Banking, online retail applications, flight reservation systems, most online purchasing applications
- It is not suitable to store media, imgaes, audio files etc for which blob storage can be used, Social networking sites - Graph database can be used.
Benefits of RDBMS :
Follows ACID properties -
Index
An index is a schema object. It is used by the server to speed up the retrieval of rows by using a pointer. Index can be created, dropped, renamed, altered.
Syntax:
CREATE INDEX index
ON TABLE column;
where the index is the name given to that index and TABLE is the name of the table on which that index is created and column is the name of that column for which it is applied.
For multiple columns:
Syntax:
CREATE INDEX index
ON TABLE (column1, column2,.....);
Unique Indexes:
Unique indexes are used for the maintenance of the integrity of the data present in the table as well as for the fast performance, it does not allow multiple values to enter into the table.
Syntax:
CREATE UNIQUE INDEX index
ON TABLE column;
When should indexes be created:
- A column contains a wide range of values.
- A column does not contain a large number of null values.
- One or more columns are frequently used together in a where clause or a join condition.
When should indexes be avoided:
- The table is small
- The columns are not often used as a condition in the query
- The column is updated frequently
A table or view can contain the following types of indexes:
Clustered
- Clustered indexes sort and store the data rows in the table or view based on their key values. These are the columns included in the index definition.
- The only time the data rows in a table are stored in sorted order is when the table contains a clustered index. When a table has a clustered index, the table is called a clustered table. If a table has no clustered index, its data rows are stored in an unordered structure called a heap.
Nonclustered
- Nonclustered indexes have a structure separate from the data rows. A nonclustered index contains the nonclustered index key values and each key value entry has a pointer to the data row that contains the key value.
Read more here - https://www.scaler.com/topics/clustered-and-non-clustered-index/
View
Comments
Post a Comment