Vous êtes sur la page 1sur 5

: What are the properties of the Relational tables?

A:
Relational tables have six properties:
Values are atomic.
Column values are of the same kind.
Each row is unique.
The sequence of columns is insignificant.
The sequence of rows is insignificant.
Each column must have a unique name.
.

Q: What is normalization?
A:
Database normalization is a data design and organization process applied to data structures based on
rules that help build relational databases. In relational database design, the process of organizing data to
minimize redundancy. Normalization usually involves dividing a database into two or more tables and
defining relationships between the tables. The objective is to isolate data so that additions, deletions,
and modifications of a field can be made in just one table and then propagated through the rest of the
database via the defined relationships.
.
Q: What are different normalization forms?
A:
1NF: Eliminate Repeating Groups
Make a separate table for each set of related attributes, and give each table a primary key. Each field
contains at most one value from its attribute domain.
2NF: Eliminate Redundant Data
If an attribute depends on only part of a multi-valued key, remove it to a separate table.
3NF: Eliminate Columns Not Dependent On Key
If attributes do not contribute to a description of the key, remove them to a separate table. All
attributes must be directly dependent on the primary key
BCNF: Boyce-Codd Normal Form

If there are non-trivial dependencies between candidate key attributes, separate them out into distinct
tables.
4NF: Isolate Independent Multiple Relationships
No table may contain two or more 1:n or n:m relationships that are not directly related.
5NF: Isolate Semantically Related Multiple Relationships
There may be practical constrains on information that justify separating logically related many-to-many
relationships.
ONF: Optimal Normal Form
A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.
DKNF: Domain-Key Normal Form
A model free from all modification anomalies.
Remember, these normalization guidelines are cumulative. For a database to be in 3NF, it must first
fulfill all the criteria of a 2NF and 1NF database.
.
Q: What is an execution plan? When would you use it? How would you view the execution plan?
A:
An execution plan is basically a road map that graphically or textually shows the data retrieval methods
chosen by the SQL Server query optimizer for a stored procedure or ad-hoc query and is a very useful
tool for a developer to understand the performance characteristics of a query or stored procedure since
the plan is the one that SQL Server will place in its cache and use to execute the stored procedure or
query. From within Query Analyzer is an option called "Show Execution Plan" (located on the Query
drop-down menu). If this option is turned on it will display query execution plan in separate window
when query is ran again.
.
Q: List few advantages of Stored Procedure.
A:
Stored procedure can reduced network traffic and latency, boosting application performance.

Stored procedure execution plans can be reused, staying cached in SQL Server's memory, reducing
server overhead.
Stored procedures help promote code reuse.
Stored procedures can encapsulate logic. You can change stored procedure code without affecting
clients.
Stored procedures provide better security to your data.
.

Q: What are the advantages of VIEW ?


A:
To protect some of the columns of a table from other users.
To hide complexity of a query.
To hide complexity of calculations.
.

Q: What is difference between UNIQUE and PRIMARY KEY constraints?


A: A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. The
columns that compose PK are automatically define NOT NULL, whereas a column that compose a
UNIQUE is not automatically defined to be mandatory must also specify the column is NOT NULL.

Q: What is ON DELETE CASCADE ?


A: When ON DELETE CASCADE is specified ORACLE maintains referential integrity by automatically
removing dependent foreign key values if a referenced primary or unique key value is removed

Q: What is a join ? Explain the different types of joins ?


A: Join is a query which retrieves related columns or rows from multiple tables.
Self Join - Joining the table with itself.
Equi Join - Joining two tables by equating two common columns.
Non-Equi Join - Joining two tables by equating two common columns.
Outer Join - Joining two tables in such a way that query can also retrieve rows that do not have
corresponding join value in the other table. . Outer Join is used where you can query all the rows of one
of the tables in the join condition even though they dont satisfy the join condition.

Q: When do you use WHERE clause and when do you use HAVING clause?
A: HAVING clause is used when you want to specify a condition for a group function and it is written
after GROUP BY clause. The WHERE clause is used when you want to specify a condition for columns,
single row functions except group functions and it is written before GROUP BY clause if it is used.

Q: Which is more faster - IN or EXISTS?


A: EXISTS is more faster than IN because EXISTS returns a Boolean value whereas IN returns a value.

Q: What is difference between TRUNCATE & DELETE ?


A: TRUNCATE commits after deleting entire table i.e., can not be rolled back. Database triggers do not
fire on TRUNCATEDELETE allows the filtered deletion. Deleted records can be rolled back or
committed.Database triggers fire on DELETE. synchronized.

Q: Explain UNION,MINUS,UNION ALL, INTERSECT ?


A: INTERSECT returns all distinct rows selected by both queries.MINUS - returns all distinct rows selected
by the first query but not by the second.UNION - returns all distinct rows selected by either queryUNION
ALL - returns all rows selected by either query, including all duplicates.

Q: What is CYCLE/NO CYCLE in a Sequence ?


A: CYCLE specifies that the sequence continues to generate values after reaching either maximum or
minimum value. After pan ascending sequence reaches its maximum value, it generates its minimum
value. After a descending sequence reaches its minimum, it generates its maximum.NO CYCLE specifies
that the sequence cannot generate more values after reaching its maximum or minimum value.

Q: Can a view be updated/inserted/deleted? If Yes under what conditions ?


A: A View can be updated/deleted/inserted if it has only one base table if the view is based on columns
from one or more tables then insert, update and delete is not possible.

Q: What are the Various Master and Detail Relation ships.

A: The various Master and Detail Relationship are


NonIsolated :: The Master cannot be deleted when a child is exisiting
Isolated :: The Master can be deleted when the child is exisiting
Cascading :: The child gets deleted when the Master is deleted

Q: What is pseudo columns ? Name them?


A: pseudocolumn behaves like a table column, but is not actually stored in the table. You can select from
pseudocolumns, but you cannot insert, update, or delete their values. This section describes these
pseudocolumns:
CURRVAL
NEXTVAL
LEVEL
ROWID
ROWNUM .

Q: What are various constraints used in SQL?


A: NULL
NOT NULL
CHECK
DEFAULT

Vous aimerez peut-être aussi