What Is A Relationship in SQL and What Are Its Types?

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 1

SQL

What is a relationship in SQL and what are its types?


A relation between multiple entities or multiple tangible and intangible objects that have
something to do with each other is known as a relationship. There are 4 types of relationships
in SQL:
1. One-to-One
2. One-to-Many/Many-to-One
3. Many-to-Many
4. Self-referencing relationships.

Explain an index and its types?


An index or a database index can be referred to as a special lookup table that makes the data
retrieval operation much faster. It consumes more memory and additional writes in order to
search the data faster. An index can be of 4 types:
1. Unique Index
2. Non-Unique Index
3. Clustered Index

What do you know about constraints in SQL?


Constraints determine what type of data will be entered in the table. They are specified
during the creation of the table and can be applied to a single field or multiple fields. The
constraints in SQL are:
NOT NULL- Prevents NULL value to be entered in a field.
CHECK- Checks if all the values in a field satisfy the given condition.
DEFAULT- Assigns a default value to a field automatically if no value has been entered.
UNIQUE- Allows only unique values to be entered in a field.
INDEX- Indexes a field providing faster retrieval of records.
PRIMARY KEY- Uniquely identifies each record in a table.
FOREIGN KEY- Restraints actions that could harm the links between tables.

You might also like