0% found this document useful (0 votes)
30 views

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

This document discusses relationships, indexes, and constraints in SQL. There are four types of relationships: one-to-one, one-to-many/many-to-one, many-to-many, and self-referencing. Indexes make data retrieval faster but use more memory, with four types: unique, non-unique, clustered, and nonclustered. Constraints determine allowed data types and include NOT NULL, CHECK, DEFAULT, UNIQUE, PRIMARY KEY, FOREIGN KEY.

Uploaded by

dchandra15
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

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

This document discusses relationships, indexes, and constraints in SQL. There are four types of relationships: one-to-one, one-to-many/many-to-one, many-to-many, and self-referencing. Indexes make data retrieval faster but use more memory, with four types: unique, non-unique, clustered, and nonclustered. Constraints determine allowed data types and include NOT NULL, CHECK, DEFAULT, UNIQUE, PRIMARY KEY, FOREIGN KEY.

Uploaded by

dchandra15
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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