SlideShare ist ein Scribd-Unternehmen logo
1 von 10
Downloaden Sie, um offline zu lesen
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.

Weitere Àhnliche Inhalte

Was ist angesagt?

Relational Algebra & Calculus
Relational Algebra & CalculusRelational Algebra & Calculus
Relational Algebra & CalculusAbdullah Khosa
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database ModelShishir Aryal
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMSPrateek Parimal
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMSPadamNepal1
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Beat Signer
 
Lecture 04 normalization
Lecture 04 normalization Lecture 04 normalization
Lecture 04 normalization emailharmeet
 
SQL subquery
SQL subquerySQL subquery
SQL subqueryVikas Gupta
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Serverprogrammings guru
 
Dbms
DbmsDbms
DbmsCAG
 
Enhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) ModelingEnhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) Modelingsontumax
 
Er diagrams presentation
Er diagrams presentationEr diagrams presentation
Er diagrams presentationAkanksha Jaiswal
 
joins and subqueries in big data analysis
joins and subqueries in big data analysisjoins and subqueries in big data analysis
joins and subqueries in big data analysisSanSan149
 
Top 100 SQL Interview Questions and Answers
Top 100 SQL Interview Questions and AnswersTop 100 SQL Interview Questions and Answers
Top 100 SQL Interview Questions and Answersiimjobs and hirist
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)pptGowarthini
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary treeZaid Shabbir
 

Was ist angesagt? (20)

Relational Algebra & Calculus
Relational Algebra & CalculusRelational Algebra & Calculus
Relational Algebra & Calculus
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Lecture 04 normalization
Lecture 04 normalization Lecture 04 normalization
Lecture 04 normalization
 
SQL subquery
SQL subquerySQL subquery
SQL subquery
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
 
Dbms
DbmsDbms
Dbms
 
Enhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) ModelingEnhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) Modeling
 
Er diagrams presentation
Er diagrams presentationEr diagrams presentation
Er diagrams presentation
 
joins and subqueries in big data analysis
joins and subqueries in big data analysisjoins and subqueries in big data analysis
joins and subqueries in big data analysis
 
Oracle
OracleOracle
Oracle
 
Sql Server Basics
Sql Server BasicsSql Server Basics
Sql Server Basics
 
Rdbms
RdbmsRdbms
Rdbms
 
Top 100 SQL Interview Questions and Answers
Top 100 SQL Interview Questions and AnswersTop 100 SQL Interview Questions and Answers
Top 100 SQL Interview Questions and Answers
 
Normalization
NormalizationNormalization
Normalization
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
 

Andere mochten auch

Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answersvijaybusu
 
Sql queries interview questions
Sql queries interview questionsSql queries interview questions
Sql queries interview questionsPyadav010186
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginnersRam Sagar Mourya
 
Sql ppt
Sql pptSql ppt
Sql pptAnuja Lad
 
DOAG: Visual SQL Tuning
DOAG: Visual SQL TuningDOAG: Visual SQL Tuning
DOAG: Visual SQL TuningKyle Hailey
 
SQL practice questions set - 2
SQL practice questions set - 2SQL practice questions set - 2
SQL practice questions set - 2Mohd Tousif
 
Informatica data warehousing_job_interview_preparation_guide
Informatica data warehousing_job_interview_preparation_guideInformatica data warehousing_job_interview_preparation_guide
Informatica data warehousing_job_interview_preparation_guideDhanasekar T
 
Top 9 bi interview questions answers
Top 9 bi interview questions answersTop 9 bi interview questions answers
Top 9 bi interview questions answershudsons168
 
Informational interview
Informational interviewInformational interview
Informational interviewvictoriamorgangar
 
Informatica question & answer set
Informatica question & answer setInformatica question & answer set
Informatica question & answer setPrem Nath
 

Andere mochten auch (14)

Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answers
 
Sql queries interview questions
Sql queries interview questionsSql queries interview questions
Sql queries interview questions
 
Sql queires
Sql queiresSql queires
Sql queires
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginners
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
DOAG: Visual SQL Tuning
DOAG: Visual SQL TuningDOAG: Visual SQL Tuning
DOAG: Visual SQL Tuning
 
SQL practice questions set - 2
SQL practice questions set - 2SQL practice questions set - 2
SQL practice questions set - 2
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
 
Oracle
OracleOracle
Oracle
 
Informatica data warehousing_job_interview_preparation_guide
Informatica data warehousing_job_interview_preparation_guideInformatica data warehousing_job_interview_preparation_guide
Informatica data warehousing_job_interview_preparation_guide
 
Top 9 bi interview questions answers
Top 9 bi interview questions answersTop 9 bi interview questions answers
Top 9 bi interview questions answers
 
Informational interview
Informational interviewInformational interview
Informational interview
 
Informatica question & answer set
Informatica question & answer setInformatica question & answer set
Informatica question & answer set
 
Sql
SqlSql
Sql
 

Ähnlich wie Sql interview questions and answers

Dbms Interview Question And Answer
Dbms Interview Question And AnswerDbms Interview Question And Answer
Dbms Interview Question And AnswerJagan Mohan Bishoyi
 
Relational Database Management System part II
Relational Database Management System part IIRelational Database Management System part II
Relational Database Management System part IIKavithaA19
 
Dbms Concepts
Dbms ConceptsDbms Concepts
Dbms Conceptsadukkas
 
Unit 2 DBMS.pptx
Unit 2 DBMS.pptxUnit 2 DBMS.pptx
Unit 2 DBMS.pptxssuserc8e1481
 
Database Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdfDatabase Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdfrsujeet169
 
Dbms 9: Relational Model
Dbms 9: Relational ModelDbms 9: Relational Model
Dbms 9: Relational ModelAmiya9439793168
 
DBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental conceptsDBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental conceptsKuntal Bhowmick
 
Sql interview q&a
Sql interview q&aSql interview q&a
Sql interview q&aSyed Shah
 
Sql
SqlSql
Sqlshenazk
 
Sql Interview Questions
Sql Interview QuestionsSql Interview Questions
Sql Interview Questionsarjundwh
 
153680 sqlinterview
153680  sqlinterview153680  sqlinterview
153680 sqlinterviewzdsgsgdf
 
Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Rakibul Hasan Pranto
 
1resume
1resume1resume
1resumeRobert AK
 
Database Systems - introduction
Database Systems - introductionDatabase Systems - introduction
Database Systems - introductionJananath Banuka
 

Ähnlich wie Sql interview questions and answers (20)

Codds rules & keys
Codds rules & keysCodds rules & keys
Codds rules & keys
 
Nagaraju
NagarajuNagaraju
Nagaraju
 
Dbms basic nots
Dbms basic notsDbms basic nots
Dbms basic nots
 
Dbms Interview Question And Answer
Dbms Interview Question And AnswerDbms Interview Question And Answer
Dbms Interview Question And Answer
 
Relational Database Management System part II
Relational Database Management System part IIRelational Database Management System part II
Relational Database Management System part II
 
Dbms Concepts
Dbms ConceptsDbms Concepts
Dbms Concepts
 
RDBMS
RDBMSRDBMS
RDBMS
 
Unit 2 DBMS.pptx
Unit 2 DBMS.pptxUnit 2 DBMS.pptx
Unit 2 DBMS.pptx
 
Database Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdfDatabase Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdf
 
Dbms 9: Relational Model
Dbms 9: Relational ModelDbms 9: Relational Model
Dbms 9: Relational Model
 
DBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental conceptsDBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental concepts
 
Sql interview q&a
Sql interview q&aSql interview q&a
Sql interview q&a
 
Sql
SqlSql
Sql
 
Sql Interview Questions
Sql Interview QuestionsSql Interview Questions
Sql Interview Questions
 
Sql
SqlSql
Sql
 
Sql
SqlSql
Sql
 
153680 sqlinterview
153680  sqlinterview153680  sqlinterview
153680 sqlinterview
 
Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)
 
1resume
1resume1resume
1resume
 
Database Systems - introduction
Database Systems - introductionDatabase Systems - introduction
Database Systems - introduction
 

KĂŒrzlich hochgeladen

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Dr. Mazin Mohamed alkathiri
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 

KĂŒrzlich hochgeladen (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
CĂłdigo Creativo y Arte de Software | Unidad 1
CĂłdigo Creativo y Arte de Software | Unidad 1CĂłdigo Creativo y Arte de Software | Unidad 1
CĂłdigo Creativo y Arte de Software | Unidad 1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 

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.