11/29/2018 SQL Interview Questions and Answers
Home Data Warehouse Informatica Informatica Scenarios Informatica Cloud Oracle Unix Hadoop
Search... Search
SQL Interview Questions and Answers
1. What is Normalization?
Popular Posts
Informatica Scenario Based Interview Questions with
Answers - Part 1
Normalization is the process of organizing the columns, tables of a database to minimize the
redundancy of data. Normalization involves in dividing large tables into smaller tables and
Unix Sed Command to Delete Lines in File - 15 Examples
defining relationships between them. Normalization is used in OLTP systems.
String Functions in Hive
2. What are different types of Normalization Levels or Normalization Forms?
Top Examples of Awk Command in Unix
The different types of Normalization Forms are:
Sed Command in Unix and Linux Examples
First Normal Form: Duplicate columns from the same table needs to be eliminated. Design/Implement/Create SCD Type 2 Effective Date
Mapping in Informatica
We have to create separate tables for each group of related data and identify each
row with a unique column or set of columns (Primary Key) Date Functions in Hive
Second Normal Form: First it should meet the requirement of first normal form.
Removes the subsets of data that apply to multiple rows of a table and place them in SQL Queries Interview Questions - Oracle Part 1
separate tables. Relationships must be created between the new tables and their
predecessors through the use of foreign keys. Top Unix Interview Questions - Part 1
Third Normal Form: First it should meet the requirements of second normal form. Update Strategy Transformation in Informatica
Remove columns that are not depending upon the primary key.
Fourth Normal Form: There should not be any multi-valued dependencies.
Have Questions? Follow Me
Most databases will be in Third Normal Form
3. What is De-normalization?
De-normalization is the process of optimizing the read performance of a database by adding
redundant data or by grouping data. De-normalization is used in OLAP systems.
https://www.folkstalk.com/2012/01/sql-interview-questions-basics-part-1.html 1/5
11/29/2018 SQL Interview Questions and Answers
vijay bhaskar
4. What is a Transaction? Add to circles
A transaction is a logical unit of work performed against a database in which all steps must be
performed or none.
5. What are ACID properties?
A database transaction must be Atomic, Consistent, Isolation and Durability.
Atomic: Transactions must be atomic. Transactions must fail or succeed as a single
unit.
Consistent: The database must always be in consistent state. There should not be
any partial transactions
Isolation: The changes made by a user should be visible only to that user until the
transaction is committed.
Durability: Once a transaction is committed, it should be permanent and cannot be 994 have me in circles View all
undone.
6. Explain different storage models of OLAP?
MOLAP: The data is stored in multi-dimensional cube. The storage is not in the
relational database, but in proprietary formats.
ROLAP: ROLAP relies on manipulating the data stored in the RDBMS for slicing and
dicing functionality.
HOLAP: HOLAP combines the advantages of both MOLAP and ROLAP. For
summary type information, HOLAP leverages on cube technology for faster
performance. For detail information, HOLAP can drill through the cube.
7. Explain one-to-one relationship with an example?
One to one relationship is a simple reference between two tables. Consider Customer and
Address tables as an example. A customer can have only one address and an address
references only one customer.
8. Explain one-to-many relationship with an example?
One-to-many relationships can be implemented by splitting the data into two tables with a
https://www.folkstalk.com/2012/01/sql-interview-questions-basics-part-1.html 2/5
11/29/2018 SQL Interview Questions and Answers
primary key and foreign key relationship. Here the row in one table is referenced by one or more
rows in the other table. An example is the Employees and Departments table, where the row in
the Departments table is referenced by one or more rows in the Employees table.
9. Explain many-to-many relationship with an example?
Many-to-Many relationship is created between two tables by creating a junction table with the
key from both the tables forming the composite primary key of the junction table.
An example is Students, Subjects and Stud_Sub_junc tables. A student can opt for one or more
subjects in a year. Similarly a subject can be opted by one or more students. So a junction table
is created to implement the many-to-many relationship.
10. Write down the general syntax of a select statement?
The basic syntax of a select statement is
SELECT Columns | *
FROM Table_Name
[WHERE Search_Condition]
[GROUP BY Group_By_Expression]
[HAVING Search_Condition]
[ORDER BY Order_By_Expression [ASC|DESC]]
11. What are the differences between Truncate and Delete?
Both truncate and delete are used to delete data from a table. The following are the differences
between the truncate and delete statements.
Truncate is a DDL statement. Delete is a DML statement
Truncate does not generate rollback segments. Whereas Delete does.
In case of delete, rollback recovers data before issuing a commit. In case of truncate,
you cannot recover data.
Truncate does not fire any delete triggers created on the table. Whereas the delete
does.
https://www.folkstalk.com/2012/01/sql-interview-questions-basics-part-1.html 3/5
11/29/2018 SQL Interview Questions and Answers
12. What are the differences between Having and Where clause?
The Where clause filters rows before grouping. Having clause filters rows after
grouping.
You cannot use aggregate functions in Where clause. In Having clause, you can use
aggregate functions.
13. How to delete duplicate records in a table?
DELETE FROM <table name>
WHERE <primary key columns> NOT IN
(SELECT MAX(rowid) FROM <table name>
Group by <primary key columns>;
14. What are the differences between UNION and UNION ALL.
Union and union all are used to merge rows from two or more tables.
Union set operator removes duplicate records. Whereas union all does not.
Union operator sorts the data in ascending order. union all does not.
Union all is faster than union operator.
15. What is primary key, foreign key and unique key?
Primary key: The primary key is used to uniquely identify each row in a table and
does not allow null values.
Foreign key: A foreign key is one or more columns whose values are based on the
primary key values from another table.
Unique Key: Unique key identifies a each row in the table uniquely. Unique key
allows null values.
Recommended Reading:
For interview questions on sql queries, check the below links:
SQL query interview questions - part1
https://www.folkstalk.com/2012/01/sql-interview-questions-basics-part-1.html 4/5
11/29/2018 SQL Interview Questions and Answers
SQL query scenario interview questions - part2
SQL queries interview questions - part3
SQL queries scenario interview questions - part4
No comments:
Post a Comment
Enter your comment...
Comment as: Google Accoun
Publish Preview
Newer Post Home Older Post
Subscribe to: Post Comments (Atom)
https://www.folkstalk.com/2012/01/sql-interview-questions-basics-part-1.html 5/5