SlideShare a Scribd company logo
2
Most read
http://itntechnicalinterview.blogspot.com
http://itntechnicalinterview.blogspot.com
Database Fundamentals
Explain codd’s rules.
1. Foundation Rule
A relational database management system must manage its stored data using only its relational
capabilities.
2. Information Rule
All information in the database should be represented in one and only one way - as values in a
table.
3. Guaranteed Access Rule
Each and every datum (atomic value) is guaranteed to be logically accessible by resorting to a
combination of table name, primary key value and column name.
4. Systematic Treatment of Null Values
Null values (distinct from empty character string or a string of blank characters and distinct from
zero or any other number) are supported in the fully relational DBMS for representing missing
information in a systematic way, independent of data type.
5. Dynamic On-line Catalog Based on the Relational Model
The database description is represented at the logical level in the same way as ordinary data, so
authorized users can apply the same relational language to its interrogation as they apply to
regular data.
6. Comprehensive Data Sublanguage Rule
A relational system may support several languages and various modes of terminal use. However,
there must be at least one language whose statements are expressible, per some well-defined
syntax, as character strings and whose ability to support all of the following is comprehensible:
a. data definition
b. view definition
c. data manipulation (interactive and by program)
d. integrity constraints
e. authorization
f. transaction boundaries (begin, commit, and rollback).
7. View Updating Rule
All views that are theoretically updateable are also updateable by the system.
8. High-level Insert, Update, and Delete
The capability of handling a base relation or a derived relation as a single operand applies nor
only to the retrieval of data but also to the insertion, update, and deletion of data.
9. Physical Data Independence
Application programs and terminal activities remain logically unimpaired whenever any changes
are made in either storage representation or access methods.
10. Logical Data Independence
Application programs and terminal activities remain logically unimpaired when information
preserving changes of any kind that theoretically permit unimpairment are made to the base
tables.
11. Integrity Independence
Integrity constraints specific to a particular relational database must be definable in the
relational data sublanguage and storable in the catalog, not in the application programs.
12. Distribution Independence
The data manipulation sublanguage of a relational DBMS must enable application programs and
http://itntechnicalinterview.blogspot.com
http://itntechnicalinterview.blogspot.com
terminal activities to remain logically unimpaired whether and whenever data are physically
centralized or distributed.
13. Nonsubversion Rule
If a relational system has or supports a low-level (single-record-at-a-time) language, that low-
level language cannot be used to subvert or bypass the integrity rules or constraints expressed
in the higher-level (multiple-records-at-a-time) relational language.
If any 6 rules are satisfied with the database then that will comes under RDBMS.
What is database?
A database is a logically coherent collection of data with some inherent meaning, representing some
aspect of real world and which is designed, built and populated with data for a specific purpose.
What is DBMS?
It is a collection of programs that enables user to create and maintain a database. In other words it is
general-purpose software that provides the users with the processes of defining, constructing and
manipulating the database for various applications.
What is RDBMS?
Relational Data Base Management Systems (RDBMS) are database management systems that maintain
data records and indices in tables. Relationships may be created and maintained across and among the
data and tables. In a relational database, relationships between data items are expressed by means of
tables. Interdependencies among these tables are expressed by data values rather than by pointers. This
allows a high degree of data independence. An RDBMS has the capability to recombine the data items
from different files, providing powerful tools for data usage.
Describe the three levels of data abstraction?
There three levels of abstraction:
1. Physical level: The lowest level of abstraction describes how data are stored.
2. Logical level: The next higher level of abstraction, describes what data are stored in database
and what relationship among those data.
3. View level: The highest level of abstraction describes only part of entire database.
Define the "integrity rules"?
There are two Integrity rules.
1. Entity Integrity: States that "Primary key cannot have NULL value"
2. Referential Integrity: States that "Foreign Key can be either a NULL value or should be Primary
Key value of other relation.
http://itntechnicalinterview.blogspot.com
http://itntechnicalinterview.blogspot.com
What is Data Independence?
Data independence means that "the application is independent of the storage structure and access
strategy of data". In other words, the ability to modify the schema definition in one level should not
affect the schema definition in the next higher level.
Two types of Data Independence:
1. Physical Data Independence: Modification in physical level should not affect the logical level.
2. Logical Data Independence: Modification in logical level should affect the view level.
NOTE: Logical Data Independence is more difficult to achieve
What is Data Model?
A collection of conceptual tools for describing data, data relationships data semantics and constraints.
What is Object Oriented model?
This model is based on collection of objects. An object contains values stored in instance variables with
in the object. An object also contains bodies of code that operate on the object. These bodies of code
are called methods. Objects that contain same types of values and the same methods are grouped
together into classes.
What is E-R model?
This data model is based on real world that consists of basic objects called entities and of relationship
among these objects. Entities are described in a database by a set of attributes.
What is an Entity?
It is a 'thing' in the real world with an independent existence.
What is Weak Entity set?
An entity set may not have sufficient attributes to form a primary key, and its primary key compromises
of its partial key and primary key of its parent entity, then it is said to be Weak Entity set.
What is an attribute?
It is a particular property, which describes the entity.
What is a Relation Schema and a Relation?
A relation Schema denoted by R(A1, A2, ..., An) is made up of the relation name R and the list of
attributes Ai that it contains. A relation is defined as a set of tuples. Let r be the relation which contains
set tuples (t1, t2, t3, ..., tn). Each tuple is an ordered list of n-values t=(v1,v2, ..., vn).
http://itntechnicalinterview.blogspot.com
http://itntechnicalinterview.blogspot.com
What is degree of a Relation?
It is the number of attribute of its relation schema.
What is Relationship?
It is an association among two or more entities.
Explain one-to-many relationship with an example?
One-to-many relationships can be implemented by splitting the data into two tables with a 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.
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.
What is Relational Algebra?
It is procedural query language. It consists of a set of operations that take one or two relations as input
and produce a new relation.
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 derived from the primary
key values of same or different table.
 Unique Key: Unique key identifies a each row in the table uniquely. Unique key allows null
values.
What is meant by query optimization?
The phase that identifies an efficient execution plan for evaluating a query that has the least estimated
cost is referred to as query optimization.
http://itntechnicalinterview.blogspot.com
http://itntechnicalinterview.blogspot.com
Normalization
What is normalization?
It is the process of efficiently organizing the data. It is the decomposition of a table into several tables to
remove the undesirable properties. For that the relation schema is analyzed their Functional
Dependencies (FDs) and primary key.
So it is a systematic method to decompose a table. The design must be dependency preserving, content
preserving (lossless join) and free from interrelation join constraints.
We need to have a formal algorithmic approach to find if there are problems in a proposed table design.
If the table structure is not proper then there will be problems like redundancy, insertion, deletion and
update anomalies.
Database communities have developed a series of guidelines to ensure that the databases are
normalized. These are referred to as normal forms numbered from one to six.
What is 1 NF (Normal Form)?
The domain of attribute must include only atomic (simple, indivisible) values.
What is 2NF?
A relation schema R is in 2NF if it is in 1NF and every non-prime attribute A in R is fully functionally
dependent on primary key.
What is 3NF?
A relation schema R is in 3NF if it is in 2NF and if every non prime attribute is non-transitively dependent
on primary key.
What is BCNF (Boyce-Codd Normal Form)?
A relation schema R is in BCNF if it is in 3NF and for every FD X  A, X must be a candidate key.
What is Functional Dependency?
For any two tuples t1 and t2 in relation ,r,
if t1[X] = t2[X] then they have t1[Y] = t2[Y].
This means the value of X component of a tuple uniquely determines the value of component Y.
Eg. RollNo determines Name or Name is dependent on RollNo
http://itntechnicalinterview.blogspot.com
http://itntechnicalinterview.blogspot.com
What is Fully Functional dependency?
It is based on concept of full functional dependency. A functional dependency X  Y is full functional
dependency if removal of any attribute A from X means that the dependency does not hold any more.
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.
Transactions
What is a Transaction?
A transaction is a logical unit of work performed against a database in which all steps must be
performed or none.
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 undone.
SQL
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]]
What are the differences between Truncate and Delete?
http://itntechnicalinterview.blogspot.com
http://itntechnicalinterview.blogspot.com
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.
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.
How to delete duplicate records in a table?
DELETE FROM <table name>
WHERE rowid in
(SELECT MAX(rowid) FROM <table name>
Group by <primary key columns>;
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.
What is ROWID and rownum in oracle?
The ROWID is a unique database-wide physical address for every row on every table. Once
assigned (when the row is first inserted into the database), it never changes until the row is deleted or
the table is dropped.
The ROWID consists of the following three components, the combination of which uniquely
identifies the physical storage location of the row.
 Oracle database file number, which contains the block with the rows
 Oracle block address, which contains the row
 The row within the block (because each block can hold many rows)
The ROWID is used internally in indexes as a quick means of retrieving rows with a particular key
value. Application developers also use it in SQL statements as a quick way to access a row once they
know the ROWID
Rownum is temporary serial number allocated to each returned row during query execution. Rownum is
a pseudo column which is generated for query data set at runtime.
http://itntechnicalinterview.blogspot.com
http://itntechnicalinterview.blogspot.com
The difference between ROWNUM and ROWID is that ROWNUM is temporary while ROWID is
permanent. Another difference is that ROWID can be used to fetch a row, while ROWNUM only has
meaning within the context of a single SQL statement, a way of referencing rows within a fetched result
set.
16. What are different Types of Join?
1. Cross Join A cross join that does not have a WHERE clause produces the Cartesian product of the
tables involved in the join. The size of a Cartesian product result set is the number of rows in the
first table multiplied by the number of rows in the second table. The common example is when
company wants to combine each product with a pricing table to analyze each product at each
price.
2. Inner Join A join that displays only the rows that have a match in both joined tables is known as
inner Join. This is the default type of join in the Query and View Designer.
3. Outer Join A join that includes rows even if they do not have related rows in the joined table is
an Outer Join. You can create three different outer join to specify the unmatched rows to be
included:
1. Left Outer Join: In Left Outer Join all rows in the first-named table i.e. "left" table, which
appears leftmost in the JOIN clause are included. Unmatched rows in the right table do
not appear.
2. Right Outer Join: In Right Outer Join all rows in the second-named table i.e. "right"
table, which appears rightmost in the JOIN clause are included. Unmatched rows in the
left table are not included.
3. Full Outer Join: In Full Outer Join all rows in all joined tables are included, whether they
are matched or not.
4. Self Join This is a particular case when one table joins to itself, with one or two aliases to avoid
confusion. A self join can be of any type, as long as the joined tables are the same. A self join is
rather unique in that it involves a relationship with only one table. The common example is
when company has a hierarchal reporting structure whereby one member of staff reports to
another. Self Join can be Outer Join or Inner Join.
PL/SQL
12. What is Cursor?
Cursor is a database object used by applications to manipulate data in a set on a row-by- row basis,
instead of the typical SQL commands that operate on all the rows in the set at one time.
In order to work with a cursor we need to perform some steps in the following order:
1. Declare cursor
2. Open cursor
3. Fetch row from the cursor
4. Process fetched row
5. Close cursor
http://itntechnicalinterview.blogspot.com
http://itntechnicalinterview.blogspot.com
6. Deallocate cursor
What is a Trigger?
Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE
or DELETE operation takes place on a table. Triggers can’t be invoked on demand. They get triggered
only when an associated action (INSERT, UPDATE, and DELETE) happens on the table on which they are
defined. Triggers are generally used to implement business rules, auditing. Triggers can also be used to
extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead
of triggers, as constraints are much faster.
What is De-normalization?
As the name indicates, de-normalization is the reverse process of normalization. It’s the controlled
introduction of redundancy in to the database design.
It helps improve the query performance as the number of joins could be reduced.
What is a Stored Procedure?
Stored Procedure is a group of sql statements that has been created once and stored in server database.
Stored procedures will accept input parameters so that single stored procedure can be used over
network by multiple clients using different input data. Stored procedures will reduce network traffic and
increase the performance.
Advantages
a) Stored procedure allows modular programming.
You can create the procedure once, store it in the database, and call it any number of times in your
program.
b) Stored Procedure allows faster execution.
If the operation requires a large amount of SQL code is performed repetitively, stored procedures can be
faster. They are parsed and optimized when they are first executed, and a compiled version of the
stored procedure remains in memory cache for later use. This means the stored procedure does not
need to be reparsed and reoptimized with each use resulting in much faster execution times.
c) Stored Procedure can reduce network traffic.
An operation requiring hundreds of lines of Transact-SQL code can be performed through a single
statement that executes the code in a procedure, rather than by sending hundreds of lines of code over
the network.
d) Stored procedures provide better security to your data
http://itntechnicalinterview.blogspot.com
http://itntechnicalinterview.blogspot.com
Users can be granted permission to execute a stored procedure even if they do not have permission to
execute the procedure's statements directly.

More Related Content

PPTX
Solid principles
PDF
Better than you think: Handling JSON data in ClickHouse
PDF
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
PPTX
Spring Security 5
DOC
Oracle Complete Interview Questions
PDF
Hibernate I
PDF
Solid NodeJS with TypeScript, Jest & NestJS
PPTX
ASP.NET MVC Presentation
Solid principles
Better than you think: Handling JSON data in ClickHouse
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
Spring Security 5
Oracle Complete Interview Questions
Hibernate I
Solid NodeJS with TypeScript, Jest & NestJS
ASP.NET MVC Presentation

What's hot (20)

PDF
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
PPTX
ASP.NET - Life cycle of asp
PDF
MongoDB Aggregation Framework
PPT
SSIS Presentation
PPTX
Solid principles
PPTX
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
PDF
MySQL: Indexing for Better Performance
PDF
Top 65 SQL Interview Questions and Answers | Edureka
PDF
ClickHouse Materialized Views: The Magic Continues
PPTX
SOLID Principles
PPT
Introduction to MongoDB
PPTX
Introduction à spring boot
PDF
Database migrations with Flyway and Liquibase
PDF
Informatica question & answer set
PDF
Advanced SQL injection to operating system full control (whitepaper)
PPTX
SOLID Principles
PDF
SwiftUI For Production | try! Swift 2019
PDF
Open Source 101 2022 - MySQL Indexes and Histograms
PDF
REST APIs with Spring
PDF
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
ASP.NET - Life cycle of asp
MongoDB Aggregation Framework
SSIS Presentation
Solid principles
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
MySQL: Indexing for Better Performance
Top 65 SQL Interview Questions and Answers | Edureka
ClickHouse Materialized Views: The Magic Continues
SOLID Principles
Introduction to MongoDB
Introduction à spring boot
Database migrations with Flyway and Liquibase
Informatica question & answer set
Advanced SQL injection to operating system full control (whitepaper)
SOLID Principles
SwiftUI For Production | try! Swift 2019
Open Source 101 2022 - MySQL Indexes and Histograms
REST APIs with Spring
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Ad

Viewers also liked (16)

PDF
Top 100 SQL Interview Questions and Answers
DOC
Sql queries with answers
ODT
Sql queries interview questions
DOC
Sql queires
DOC
A must Sql notes for beginners
PPT
Sql ppt
PPTX
DOAG: Visual SQL Tuning
DOC
SQL practice questions set - 2
DOC
Dbms lab questions
PPTX
SQL Basics
PDF
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
DOC
PDF
Informatica data warehousing_job_interview_preparation_guide
DOC
Top 9 bi interview questions answers
DOCX
Informational interview
PPT
Top 100 SQL Interview Questions and Answers
Sql queries with answers
Sql queries interview questions
Sql queires
A must Sql notes for beginners
Sql ppt
DOAG: Visual SQL Tuning
SQL practice questions set - 2
Dbms lab questions
SQL Basics
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Informatica data warehousing_job_interview_preparation_guide
Top 9 bi interview questions answers
Informational interview
Ad

Similar to Sql interview questions and answers (20)

PPTX
Codds rules & keys
PPTX
codd rules of dbms given by E F codd who is called father of dbms
PPTX
Introduction to database
PPTX
DBMS (1).pptx
PDF
RDBMS NOTES 1.pdf BWSBFDGFEDRHHYGTRFEDCWXSDFRGTHYUJ7IK89O8IJUY7HGTR
PDF
Basics of DBMS - Traditional File System
PPT
D B M S Animate
PPTX
Relational Database Management System part II
PPTX
RDBMS to NoSQL. An overview.
PPTX
DBMS DATA MANAGEMENT SYSTEM ppt Cs403 rtc
PDF
Database Systems - introduction
PPTX
Introduction to Database Management Systems (DBMS)
PPTX
ip class 12 cnsddidsnfsdifsdbfuodfd (1).pptx
DOCX
Technical Note on DBMS
PPTX
Database Basics
PDF
PPTX
Unit 2 DBMS.pptx
PPTX
SQL-queries-for-Data-Analysts-Updated.pptx
PDF
Rdbms concepts
DOCX
Dbms Concepts
Codds rules & keys
codd rules of dbms given by E F codd who is called father of dbms
Introduction to database
DBMS (1).pptx
RDBMS NOTES 1.pdf BWSBFDGFEDRHHYGTRFEDCWXSDFRGTHYUJ7IK89O8IJUY7HGTR
Basics of DBMS - Traditional File System
D B M S Animate
Relational Database Management System part II
RDBMS to NoSQL. An overview.
DBMS DATA MANAGEMENT SYSTEM ppt Cs403 rtc
Database Systems - introduction
Introduction to Database Management Systems (DBMS)
ip class 12 cnsddidsnfsdifsdbfuodfd (1).pptx
Technical Note on DBMS
Database Basics
Unit 2 DBMS.pptx
SQL-queries-for-Data-Analysts-Updated.pptx
Rdbms concepts
Dbms Concepts

Recently uploaded (20)

PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Classroom Observation Tools for Teachers
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Lesson notes of climatology university.
PPTX
Institutional Correction lecture only . . .
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Types and Its function , kingdom of life
PPH.pptx obstetrics and gynecology in nursing
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Classroom Observation Tools for Teachers
Microbial diseases, their pathogenesis and prophylaxis
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Module 4: Burden of Disease Tutorial Slides S2 2025
O7-L3 Supply Chain Operations - ICLT Program
TR - Agricultural Crops Production NC III.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Complications of Minimal Access Surgery at WLH
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Microbial disease of the cardiovascular and lymphatic systems
Lesson notes of climatology university.
Institutional Correction lecture only . . .
Pharma ospi slides which help in ospi learning
Cell Types and Its function , kingdom of life

Sql interview questions and answers

  • 1. http://itntechnicalinterview.blogspot.com http://itntechnicalinterview.blogspot.com Database Fundamentals Explain codd’s rules. 1. Foundation Rule A relational database management system must manage its stored data using only its relational capabilities. 2. Information Rule All information in the database should be represented in one and only one way - as values in a table. 3. Guaranteed Access Rule Each and every datum (atomic value) is guaranteed to be logically accessible by resorting to a combination of table name, primary key value and column name. 4. Systematic Treatment of Null Values Null values (distinct from empty character string or a string of blank characters and distinct from zero or any other number) are supported in the fully relational DBMS for representing missing information in a systematic way, independent of data type. 5. Dynamic On-line Catalog Based on the Relational Model The database description is represented at the logical level in the same way as ordinary data, so authorized users can apply the same relational language to its interrogation as they apply to regular data. 6. Comprehensive Data Sublanguage Rule A relational system may support several languages and various modes of terminal use. However, there must be at least one language whose statements are expressible, per some well-defined syntax, as character strings and whose ability to support all of the following is comprehensible: a. data definition b. view definition c. data manipulation (interactive and by program) d. integrity constraints e. authorization f. transaction boundaries (begin, commit, and rollback). 7. View Updating Rule All views that are theoretically updateable are also updateable by the system. 8. High-level Insert, Update, and Delete The capability of handling a base relation or a derived relation as a single operand applies nor only to the retrieval of data but also to the insertion, update, and deletion of data. 9. Physical Data Independence Application programs and terminal activities remain logically unimpaired whenever any changes are made in either storage representation or access methods. 10. Logical Data Independence Application programs and terminal activities remain logically unimpaired when information preserving changes of any kind that theoretically permit unimpairment are made to the base tables. 11. Integrity Independence Integrity constraints specific to a particular relational database must be definable in the relational data sublanguage and storable in the catalog, not in the application programs. 12. Distribution Independence The data manipulation sublanguage of a relational DBMS must enable application programs and
  • 2. http://itntechnicalinterview.blogspot.com http://itntechnicalinterview.blogspot.com terminal activities to remain logically unimpaired whether and whenever data are physically centralized or distributed. 13. Nonsubversion Rule If a relational system has or supports a low-level (single-record-at-a-time) language, that low- level language cannot be used to subvert or bypass the integrity rules or constraints expressed in the higher-level (multiple-records-at-a-time) relational language. If any 6 rules are satisfied with the database then that will comes under RDBMS. What is database? A database is a logically coherent collection of data with some inherent meaning, representing some aspect of real world and which is designed, built and populated with data for a specific purpose. What is DBMS? It is a collection of programs that enables user to create and maintain a database. In other words it is general-purpose software that provides the users with the processes of defining, constructing and manipulating the database for various applications. What is RDBMS? Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage. Describe the three levels of data abstraction? There three levels of abstraction: 1. Physical level: The lowest level of abstraction describes how data are stored. 2. Logical level: The next higher level of abstraction, describes what data are stored in database and what relationship among those data. 3. View level: The highest level of abstraction describes only part of entire database. Define the "integrity rules"? There are two Integrity rules. 1. Entity Integrity: States that "Primary key cannot have NULL value" 2. Referential Integrity: States that "Foreign Key can be either a NULL value or should be Primary Key value of other relation.
  • 3. http://itntechnicalinterview.blogspot.com http://itntechnicalinterview.blogspot.com What is Data Independence? Data independence means that "the application is independent of the storage structure and access strategy of data". In other words, the ability to modify the schema definition in one level should not affect the schema definition in the next higher level. Two types of Data Independence: 1. Physical Data Independence: Modification in physical level should not affect the logical level. 2. Logical Data Independence: Modification in logical level should affect the view level. NOTE: Logical Data Independence is more difficult to achieve What is Data Model? A collection of conceptual tools for describing data, data relationships data semantics and constraints. What is Object Oriented model? This model is based on collection of objects. An object contains values stored in instance variables with in the object. An object also contains bodies of code that operate on the object. These bodies of code are called methods. Objects that contain same types of values and the same methods are grouped together into classes. What is E-R model? This data model is based on real world that consists of basic objects called entities and of relationship among these objects. Entities are described in a database by a set of attributes. What is an Entity? It is a 'thing' in the real world with an independent existence. What is Weak Entity set? An entity set may not have sufficient attributes to form a primary key, and its primary key compromises of its partial key and primary key of its parent entity, then it is said to be Weak Entity set. What is an attribute? It is a particular property, which describes the entity. What is a Relation Schema and a Relation? A relation Schema denoted by R(A1, A2, ..., An) is made up of the relation name R and the list of attributes Ai that it contains. A relation is defined as a set of tuples. Let r be the relation which contains set tuples (t1, t2, t3, ..., tn). Each tuple is an ordered list of n-values t=(v1,v2, ..., vn).
  • 4. http://itntechnicalinterview.blogspot.com http://itntechnicalinterview.blogspot.com What is degree of a Relation? It is the number of attribute of its relation schema. What is Relationship? It is an association among two or more entities. Explain one-to-many relationship with an example? One-to-many relationships can be implemented by splitting the data into two tables with a 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. 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. What is Relational Algebra? It is procedural query language. It consists of a set of operations that take one or two relations as input and produce a new relation. 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 derived from the primary key values of same or different table.  Unique Key: Unique key identifies a each row in the table uniquely. Unique key allows null values. What is meant by query optimization? The phase that identifies an efficient execution plan for evaluating a query that has the least estimated cost is referred to as query optimization.
  • 5. http://itntechnicalinterview.blogspot.com http://itntechnicalinterview.blogspot.com Normalization What is normalization? It is the process of efficiently organizing the data. It is the decomposition of a table into several tables to remove the undesirable properties. For that the relation schema is analyzed their Functional Dependencies (FDs) and primary key. So it is a systematic method to decompose a table. The design must be dependency preserving, content preserving (lossless join) and free from interrelation join constraints. We need to have a formal algorithmic approach to find if there are problems in a proposed table design. If the table structure is not proper then there will be problems like redundancy, insertion, deletion and update anomalies. Database communities have developed a series of guidelines to ensure that the databases are normalized. These are referred to as normal forms numbered from one to six. What is 1 NF (Normal Form)? The domain of attribute must include only atomic (simple, indivisible) values. What is 2NF? A relation schema R is in 2NF if it is in 1NF and every non-prime attribute A in R is fully functionally dependent on primary key. What is 3NF? A relation schema R is in 3NF if it is in 2NF and if every non prime attribute is non-transitively dependent on primary key. What is BCNF (Boyce-Codd Normal Form)? A relation schema R is in BCNF if it is in 3NF and for every FD X  A, X must be a candidate key. What is Functional Dependency? For any two tuples t1 and t2 in relation ,r, if t1[X] = t2[X] then they have t1[Y] = t2[Y]. This means the value of X component of a tuple uniquely determines the value of component Y. Eg. RollNo determines Name or Name is dependent on RollNo
  • 6. http://itntechnicalinterview.blogspot.com http://itntechnicalinterview.blogspot.com What is Fully Functional dependency? It is based on concept of full functional dependency. A functional dependency X  Y is full functional dependency if removal of any attribute A from X means that the dependency does not hold any more. 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. Transactions What is a Transaction? A transaction is a logical unit of work performed against a database in which all steps must be performed or none. 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 undone. SQL 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]] What are the differences between Truncate and Delete?
  • 7. http://itntechnicalinterview.blogspot.com http://itntechnicalinterview.blogspot.com 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. 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. How to delete duplicate records in a table? DELETE FROM <table name> WHERE rowid in (SELECT MAX(rowid) FROM <table name> Group by <primary key columns>; 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. What is ROWID and rownum in oracle? The ROWID is a unique database-wide physical address for every row on every table. Once assigned (when the row is first inserted into the database), it never changes until the row is deleted or the table is dropped. The ROWID consists of the following three components, the combination of which uniquely identifies the physical storage location of the row.  Oracle database file number, which contains the block with the rows  Oracle block address, which contains the row  The row within the block (because each block can hold many rows) The ROWID is used internally in indexes as a quick means of retrieving rows with a particular key value. Application developers also use it in SQL statements as a quick way to access a row once they know the ROWID Rownum is temporary serial number allocated to each returned row during query execution. Rownum is a pseudo column which is generated for query data set at runtime.
  • 8. http://itntechnicalinterview.blogspot.com http://itntechnicalinterview.blogspot.com The difference between ROWNUM and ROWID is that ROWNUM is temporary while ROWID is permanent. Another difference is that ROWID can be used to fetch a row, while ROWNUM only has meaning within the context of a single SQL statement, a way of referencing rows within a fetched result set. 16. What are different Types of Join? 1. Cross Join A cross join that does not have a WHERE clause produces the Cartesian product of the tables involved in the join. The size of a Cartesian product result set is the number of rows in the first table multiplied by the number of rows in the second table. The common example is when company wants to combine each product with a pricing table to analyze each product at each price. 2. Inner Join A join that displays only the rows that have a match in both joined tables is known as inner Join. This is the default type of join in the Query and View Designer. 3. Outer Join A join that includes rows even if they do not have related rows in the joined table is an Outer Join. You can create three different outer join to specify the unmatched rows to be included: 1. Left Outer Join: In Left Outer Join all rows in the first-named table i.e. "left" table, which appears leftmost in the JOIN clause are included. Unmatched rows in the right table do not appear. 2. Right Outer Join: In Right Outer Join all rows in the second-named table i.e. "right" table, which appears rightmost in the JOIN clause are included. Unmatched rows in the left table are not included. 3. Full Outer Join: In Full Outer Join all rows in all joined tables are included, whether they are matched or not. 4. Self Join This is a particular case when one table joins to itself, with one or two aliases to avoid confusion. A self join can be of any type, as long as the joined tables are the same. A self join is rather unique in that it involves a relationship with only one table. The common example is when company has a hierarchal reporting structure whereby one member of staff reports to another. Self Join can be Outer Join or Inner Join. PL/SQL 12. What is Cursor? Cursor is a database object used by applications to manipulate data in a set on a row-by- row basis, instead of the typical SQL commands that operate on all the rows in the set at one time. In order to work with a cursor we need to perform some steps in the following order: 1. Declare cursor 2. Open cursor 3. Fetch row from the cursor 4. Process fetched row 5. Close cursor
  • 9. http://itntechnicalinterview.blogspot.com http://itntechnicalinterview.blogspot.com 6. Deallocate cursor What is a Trigger? Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table. Triggers can’t be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, and DELETE) happens on the table on which they are defined. Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster. What is De-normalization? As the name indicates, de-normalization is the reverse process of normalization. It’s the controlled introduction of redundancy in to the database design. It helps improve the query performance as the number of joins could be reduced. What is a Stored Procedure? Stored Procedure is a group of sql statements that has been created once and stored in server database. Stored procedures will accept input parameters so that single stored procedure can be used over network by multiple clients using different input data. Stored procedures will reduce network traffic and increase the performance. Advantages a) Stored procedure allows modular programming. You can create the procedure once, store it in the database, and call it any number of times in your program. b) Stored Procedure allows faster execution. If the operation requires a large amount of SQL code is performed repetitively, stored procedures can be faster. They are parsed and optimized when they are first executed, and a compiled version of the stored procedure remains in memory cache for later use. This means the stored procedure does not need to be reparsed and reoptimized with each use resulting in much faster execution times. c) Stored Procedure can reduce network traffic. An operation requiring hundreds of lines of Transact-SQL code can be performed through a single statement that executes the code in a procedure, rather than by sending hundreds of lines of code over the network. d) Stored procedures provide better security to your data
  • 10. http://itntechnicalinterview.blogspot.com http://itntechnicalinterview.blogspot.com Users can be granted permission to execute a stored procedure even if they do not have permission to execute the procedure's statements directly.