0% found this document useful (0 votes)
7 views3 pages

Understanding SQL Joins and Normalization

Uploaded by

vinnu1983
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Understanding SQL Joins and Normalization

Uploaded by

vinnu1983
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

9. What is a join?

This is a keyword used to query data from more tables based on the relationship between the fields of
the tables. Keys play a major role when JOINs are used.

10. What are the types of join and explain each?


There are various types of join which can be used to retrieve data and it depends on the relationship
between tables.
 Inner Join.
Inner join return rows when there is at least one match of rows between the tables.
 Right Join.
Right join return rows which are common between the tables and all rows of Right hand side table.
Simply, it returns all the rows from the right hand side table even though there are no matches in the
left hand side table.
 Left Join.
Left join return rows which are common between the tables and all rows of Left hand side table. Simply,
it returns all the rows from Left hand side table even though there are no matches in the Right hand side
table.
 Full Join.
Full join return rows when there are matching rows in any one of the tables. This means, it returns all
the rows from the left hand side table and all the rows from the right hand side table.

1. What is normalization?
Normalization is the process of minimizing redundancy and dependency by organizing fields and table of
a database. The main aim of Normalization is to add, delete or modify field that can be made in a single
table.

12. What is Denormalization.


DeNormalization is a technique used to access the data from higher to lower normal forms of database.
It is also process of introducing redundancy into a table by incorporating data from the related tables.
13. What are all the different normalizations?
The normal forms can be divided into 5 forms, and they are explained below -.
 First Normal Form (1NF):.
This should remove all the duplicate columns from the table. Creation of tables for the related data and
identification of unique columns.
 Second Normal Form (2NF):.
Meeting all requirements of the first normal form. Placing the subsets of data in separate tables and
Creation of relationships between the tables using primary keys.
 Third Normal Form (3NF):.
This should meet all requirements of 2NF. Removing the columns which are not dependent on primary
key constraints.
 Fourth Normal Form (3NF):.
Meeting all the requirements of third normal form and it should not have multi- valued dependencies.

14. What is a View?


A view is a virtual table which consists of a subset of data contained in a table. Views are not virtually
present, and it takes less space to store. View can have data of one or more tables combined, and it is
depending on the relationship.
15. What is an Index?
An index is performance tuning method of allowing faster retrieval of records from the table. An index
creates an entry for each value and it will be faster to retrieve data.

16. What are all the different types of indexes?


There are three types of indexes -.
 Unique Index.
This indexing does not allow the field to have duplicate values if the column is unique indexed. Unique
index can be applied automatically when primary key is defined.
 Clustered Index.
This type of index reorders the physical order of the table and search based on the key values. Each
table can have only one clustered index.
 NonClustered Index.
NonClustered Index does not alter the physical order of the table and maintains logical order of data.
Each table can have 999 nonclustered indexes.

What are the types of subquery?


There are two types of subquery – Correlated and Non-Correlated.
A correlated subquery cannot be considered as independent query, but it can refer the column in a table
listed in the FROM the list of the main query.
A Non-Correlated sub query can be considered as independent query and the output of subquery are
substituted in the main query.

What is a stored procedure?


Stored Procedure is a function consists of many SQL statement to access the database system. Several
SQL statements are consolidated into a stored procedure and execute them whenever and wherever
required.

What is the difference between DELETE and TRUNCATE commands?


DELETE command is used to remove rows from the table, and WHERE clause can be used for conditional
set of parameters. Commit and Rollback can be performed after delete statement.
TRUNCATE removes all rows from the table. Truncate operation cannot be rolled back.

What is data Integrity?


Data Integrity defines the accuracy and consistency of data stored in a database. It can also define
integrity constraints to enforce business rules on the data when it is entered into the application or
database.

What is the difference between Cluster and Non-Cluster Index?


Clustered index is used for easy retrieval of data from the database by altering the way that the records
are stored. Database sorts out rows by the column which is set to be clustered index.
A nonclustered index does not alter the way it was stored but creates a complete separate object within
the table. It point back to the original table rows after searching.

What are all types of user defined functions?


Three types of user defined functions are.
 Scalar Functions.
 Inline Table valued functions.
 Multi statement valued functions.
Scalar returns unit, variant defined the return clause. Other two types return table as a return.

Advantages and Disadvantages of Stored Procedure?


Stored procedure can be used as a modular programming – means create once, store and call for several
times whenever required. This supports faster execution instead of executing multiple queries. This
reduces network traffic and provides better security to the data.
Disadvantage is that it can be executed only in the Database and utilizes more memory in the database
server.

What is Online Transaction Processing (OLTP)?


Online Transaction Processing (OLTP) manages transaction based applications which can be used for
data entry, data retrieval and data processing. OLTP makes data management simple and efficient.
Unlike OLAP systems goal of OLTP systems is serving real-time transactions.
Example – Bank Transactions on a daily basis.

What is the difference between TRUNCATE and DROP statements?


TRUNCATE removes all the rows from the table, and it cannot be rolled back. DROP command removes a
table from the database and operation cannot be rolled back.

How can you create an empty table from an existing table?


Example will be -.
Select * into studentcopy from student where 1=2
Here, we are copying student table to another table with the same structure with no rows copied.

How to select unique records from a table?


Select unique records from a table by using DISTINCT keyword.
Select DISTINCT StudentID, StudentName from Student.

Which operator is used in query for pattern matching?


LIKE operator is used for pattern matching, and it can be used as -.
1. % - Matches zero or more characters.
2. _(Underscore) – Matching exactly one character.
Example -.
Select * from Student where studentname like 'a%'
Select * from Student where studentname like 'ami_'

What port does SQL server run on?


1433 is the standard port for SQL server.

You might also like