Sie sind auf Seite 1von 63

INDIA BIX QUESTIONS:

0.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.
1. 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.
2. What is a Database system?
The database and DBMS software together is called as Database system.
3. What are the advantages of DBMS?
1. Redundancy is controlled.
2. Unauthorised access is restricted.
3. Providing multiple user interfaces.
4. Enforcing integrity constraints.
5. Providing backup and recovery.
4. What are the disadvantage in File Processing System?
1. Data redundancy and inconsistency.
2. Difficult in accessing data.
3. Data isolation.
4. Data integrity.
5. Concurrent access is not possible.
6. Security Problems.
5. Describe the three levels of data abstraction?
The are 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.
6. 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.
7. What is extension and intension?
1. Extension: It is the number of tuples present in a table at any instance. This is
time dependent.
2. Intension: It is a constant value that gives the name, structure of table and the
constraints laid on it.
8. What is System R? What are its two major subsystems?
System R was designed and developed over a period of 1974-79 at IBM San Jose
Research Center. It is a prototype and its purpose was to demonstrate that it is possible to
build a Relational System that can be used in a real life environment to solve real life
problems, with performance at least comparable to that of existing system.
Its two subsystems are
1. Research Storage
2. System Relational Data System.
9. How is the data structure of System R different from the relational structure?
Unlike Relational systems in System R
1. Domains are not supported
2. Enforcement of candidate key uniqueness is optional
3. Enforcement of entity integrity is optional
4. Referential integrity is not enforced
10. 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
11. What is a view? How it is related to data independence?
A view may be thought of as a virtual table, that is, a table that does not really exist in its
own right but is instead derived from one or more underlying base table. In other words,
there is no stored file that direct represents the view instead a definition of view is stored
in data dictionary.
Growth and restructuring of base tables is not reflected in views. Thus the view can
insulate users from the effects of restructuring and growth in the database. Hence
accounts for logical data independence.
13. What is Data Model?
A collection of conceptual tools for describing data, data relationships data semantics and
constraints.
14. 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.
15. 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.
16. What is an Entity?
It is a 'thing' in the real world with an independent existence.
17. What is an Entity type?
It is a collection (set) of entities that have same attributes.
18. What is an Entity set?
It is a collection of all entities of particular entity type in the database.
19. What is an Extension of entity type?The collections of entities of a particular entity type
are grouped together into an entity set.
20. 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.
21. What is an attribute?
It is a particular property, which describes the entity.
22. 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).
23. What is degree of a Relation?
It is the number of attribute of its relation schema.
24. What is Relationship?
It is an association among two or more entities.
25. What is Relationship set?
The collection (or set) of similar relationships.
26. What is Relationship type?
Relationship type defines a set of associations or a relationship set among a given set of
entity types.
27. What is degree of Relationship type?
It is the number of entity type participating.
28. What is DDL (Data Definition Language)?
A data base schema is specifies by a set of definitions expressed by a special language
called DDL.
29. What is VDL (View Definition Language)?
It specifies user views and their mappings to the conceptual schema.
30. What is SDL (Storage Definition Language)?
This language is to specify the internal schema. This language may specify the mapping
between two schemas.
31. What is Data Storage - Definition Language?
The storage structures and access methods used by database system are specified by a set
of definition in a special type of DDL called data storage-definition language.
32. What is DML (Data Manipulation Language)?
This language that enable user to access or manipulate data as organised by appropriate
data model.
1. Procedural DML or Low level: DML requires a user to specify what data are
needed and how to get those data.
2. Non-Procedural DML or High level: DML requires a user to specify what data are
needed without specifying how to get those data.
33. What is DML Compiler?
It translates DML statements in a query language into low-level instruction that the query
evaluation engine can understand.
34. What is Query evaluation engine?
It executes low-level instruction generated by compiler.
35. What is DDL Interpreter?
It interprets DDL statements and record them in tables containing metadata.
36. What is Record-at-a-time?
The Low level or Procedural DML can specify and retrieve each record from a set of
records. This retrieve of a record is said to be Record-at-a-time.
37. What is Set-at-a-time or Set-oriented?
The High level or Non-procedural DML can specify and retrieve many records in a single
DML statement. This retrieve of a record is said to be Set-at-a-time or Set-oriented.
38. 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.
39. What is Relational Calculus?
It is an applied predicate calculus specifically tailored for relational databases proposed
by E.F. Codd. E.g. of languages based on it are DSL ALPHA, QUEL.
40. How does Tuple-oriented relational calculus differ from domain-oriented relational
calculus?
1. The tuple-oriented calculus uses a tuple variables i.e., variable whose only
permitted values are tuples of that relation. E.g. QUEL
2. The domain-oriented calculus has domain variables i.e., variables that range over
the underlying domains instead of over relation. E.g. ILL, DEDUCE.
41. What is normalization?
It is a process of analysing the given relation schemas based on their Functional
Dependencies (FDs) and primary key to achieve the properties
(1).Minimizing redundancy, (2). Minimizing insertion, deletion and update anomalies.
42. What is Functional Dependency?
A Functional dependency is denoted by X Y between two sets of attributes X and Y that
are subsets of R specifies a constraint on the possible tuple that can form a relation state r
of R. The constraint is for any two tuples t1 and t2 in 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.
43. What is Lossless join property?
It guarantees that the spurious tuple generation does not occur with respect to relation
schemas after decomposition.
44. What is 1 NF (Normal Form)?
The domain of attribute must include only atomic (simple, indivisible) values.
45. 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.
46. 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.
47. What is 3NF?
A relation schema R is in 3NF if it is in 2NF and for every FD X A either of the
following is true
1. X is a Super-key of R.
2. A is a prime attribute of R.
In other words, if every non prime attribute is non-transitively dependent on primary key.
48. What is BCNF (Boyce-Codd Normal Form)?
A relation schema R is in BCNF if it is in 3NF and satisfies an additional constraint that
for every FD X A, X must be a candidate key.
49. What is 4NF?
A relation schema R is said to be in 4NF if for every Multivalued dependency X Y that
holds over R, one of following is true.
1.) X is subset or equal to (or) XY = R.
2.) X is a super key.
50. What is 5NF?
A Relation schema R is said to be 5NF if for every join dependency {R1, R2, ..., Rn} that
holds R, one the following is true 1.) Ri = R for some i.
2.) The join dependency is implied by the set of FD, over R in which the left side is key
of R.
51. What is Domain-Key Normal Form?
A relation is said to be in DKNF if all constraints and dependencies that should hold on
the the constraint can be enforced by simply enforcing the domain constraint and key
constraint on the relation.
52. What are partial, alternate,, artificial, compound and natural key?
1. Partial Key: It is a set of attributes that can uniquely identify weak entities and
that are related to same owner entity. It is sometime called as Discriminator.
2. Alternate Key: All Candidate Keys excluding the Primary Key are known as
Alternate Keys.
3. Artificial Key: If no obvious key, either stand alone or compound is available,
then the last resort is to simply create a key, by assigning a unique number to each
record or occurrence. Then this is known as developing an artificial key.
4. Compound Key: If no single data element uniquely identifies occurrences within
a construct, then combining multiple elements to create a unique identifier for the
construct is known as creating a compound key.
5. Natural Key: When one of the data elements stored within a construct is utilized
as the primary key, then it is called the natural key.
53. What is indexing and what are the different kinds of indexing?
Indexing is a technique for determining how quickly specific data can be found.
Types:
1. Binary search style indexing
2. B-Tree indexing
3. Inverted list indexing
4. Memory resident table
5. Table indexing
54. What is system catalog or catalog relation? How is better known as?
A RDBMS maintains a description of all the data that it contains, information about
every relation and index that it contains. This information is stored in a collection of
relations maintained by the system called metadata. It is also called data dictionary.
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.
What is durability in DBMS?
Once the DBMS informs the user that a transaction has successfully completed, its effects should
persist even if the system crashes before all its changes are reflected on disk. This property is
called durability.
What do you mean by atomicity and aggregation?
1. Atomicity: Either all actions are carried out or none are. Users should not have to worry
about the effect of incomplete transactions. DBMS ensures this by undoing the actions of
incomplete transactions.
2. Aggregation: A concept which is used to model a relationship between a collection of
entities and relationships. It is used when we need to express a relationship among
relationships.
What is a Phantom Deadlock?
In distributed deadlock detection, the delay in propagating local information might cause the
deadlock detection algorithms to identify deadlocks that do not really exist. Such situations are
called phantom deadlocks and they lead to unnecessary aborts.
What is a checkpoint and When does it occur?
A Checkpoint is like a snapshot of the DBMS state. By taking checkpoints, the DBMS can
reduce the amount of work to be done during restart in the event of subsequent crashes.
What are the different phases of transaction?
Different phases are
1.) Analysis phase,
2.) Redo Phase,
3.) Undo phase.
61. What do you mean by flat file database?
It is a database in which there are no programs or user access languages. It has no cross-
file capabilities but is user-friendly and provides user-interface management.
62. What is "transparent DBMS"?
It is one, which keeps its Physical Structure hidden from user.
63. What is a query?
A query with respect to DBMS relates to user commands that are used to interact with a
data base. The query language can be classified into data definition language and data
manipulation language.
64. What do you mean by Correlated subquery?
Subqueries, or nested queries, are used to bring back a set of rows to be used by the
parent query. Depending on how the subquery is written, it can be executed once for the
parent query or it can be executed once for each row returned by the parent query. If the
subquery is executed for each row of the parent, this is called a correlated subquery.
A correlated subquery can be easily identified if it contains any references to the parent
subquery columns in its WHERE clause. Columns from the subquery cannot be
referenced anywhere else in the parent query. The following example demonstrates a
non-correlated subquery.
Example: Select * From CUST Where '10/03/1990' IN (Select ODATE From ORDER
Where CUST.CNUM = ORDER.CNUM)
65. What are the primitive operations common to all record management systems?
Addition, deletion and modification.
66. Name the buffer in which all the commands that are typed in are stored?
'Edit' Buffer.
67. What are the unary operations in Relational Algebra?
PROJECTION and SELECTION.
68. Are the resulting relations of PRODUCT and JOIN operation the same?
No.
PRODUCT: Concatenation of every row in one relation with every row in another.
JOIN: Concatenation of rows from one relation and related rows from another.
69. What is RDBMS KERNEL?
Two important pieces of RDBMS architecture are the kernel, which is the software, and
the data dictionary, which consists of the system-level data structures used by the kernel
to manage the database You might think of an RDBMS as an operating system (or set of
subsystems), designed specifically for controlling data access; its primary functions are
storing, retrieving, and securing data. An RDBMS maintains its own list of authorized
users and their associated privileges; manages memory caches and paging; controls
locking for concurrent resource usage; dispatches and schedules user requests; and
manages space usage within its table-space structures.
70. Name the sub-systems of a RDBMS.
I/O, Security, Language Processing, Process Control, Storage Management, Logging and
Recovery, Distribution Control, Transaction Control, Memory Management, Lock
Management.
71. Which part of the RDBMS takes care of the data dictionary? How?
Data dictionary is a set of tables and database objects that is stored in a special area of the
database and maintained exclusively by the kernel.
72. What is the job of the information stored in data-dictionary?
The information in the data dictionary validates the existence of the objects, provides
access to them, and maps the actual physical storage location.
73. How do you communicate with an RDBMS?
You communicate with an RDBMS using Structured Query Language (SQL).
74. Define SQL and state the differences between SQL and other conventional programming
Languages.
SQL is a nonprocedural language that is designed specifically for data access operations
on normalized relational database structures. The primary difference between SQL and
other conventional programming languages is that SQL statements specify what data
operations should be performed rather than how to perform them.
75. Name the three major set of files on disk that compose a database in Oracle.
There are three major sets of files on disk that compose a database. All the files are
binary. These are
1.) Database files
2.) Control files
3.) Redo logs
The most important of these are the database files where the actual data resides. The
control files and the redo logs support the functioning of the architecture itself. All three
sets of files must be present, open, and available to Oracle for any data on the database to
be useable. Without these files, you cannot access the database, and the database
administrator might have to recover some or all of the database using a backup, if there is
one.
76. What is database Trigger?
A database trigger is a PL/SQL block that can defined to automatically execute for insert,
update, and delete statements against a table. The trigger can e defined to execute once
for the entire statement or once for every row that is inserted, updated, or deleted. For any
one table, there are twelve events for which you can define database triggers. A database
trigger can call database procedures that are also written in PL/SQL.
77. What are stored-procedures? And what are the advantages of using them?
Stored procedures are database objects that perform a user defined operation. A stored
procedure can have a set of compound SQL statements. A stored procedure executes the
SQL commands and returns the result to the client. Stored procedures are used to reduce
network traffic.
78. What is Storage Manager?
It is a program module that provides the interface between the low-level data stored in
database, application programs and queries submitted to the system.
What is Buffer Manager?
It is a program module, which is responsible for fetching data from disk storage into main
memory and deciding what data to be cache in memory.
What is Transaction Manager?
It is a program module, which ensures that database, remains in a consistent state despite system
failures and concurrent transaction execution proceeds without conflicting.
What is File Manager?
It is a program module, which manages the allocation of space on disk storage and data structure
used to represent information stored on a disk.
What is Authorization and Integrity manager?
It is the program module, which tests for the satisfaction of integrity constraint and checks the
authority of user to access data.
What are stand-alone procedures?
Procedures that are not part of a package are known as stand-alone because they independently
defined. A good example of a stand-alone procedure is one written in a SQL*Forms application.
These types of procedures are not available for reference from other Oracle tools. Another
limitation of stand-alone procedures is that they are compiled at run time, which slows execution.
What are cursors give different types of cursors?
PL/SQL uses cursors for all database information accesses statements. The language supports the
use two types of cursors
1.) Implicit
2.) Explicit
85. What is cold backup and hot backup (in case of Oracle)?
1. Cold Backup: It is copying the three sets of files (database files, redo logs, and
control file) when the instance is shut down. This is a straight file copy, usually
from the disk directly to tape. You must shut down the instance to guarantee a
consistent copy. If a cold backup is performed, the only option available in the
event of data file loss is restoring all the files from the latest backup. All work
performed on the database since the last backup is lost.
2. Hot Backup: Some sites (such as worldwide airline reservations systems) cannot
shut down the database while making a backup copy of the files. The cold backup
is not an available option.
86. What is meant by Proactive, Retroactive and Simultaneous Update.
1. Proactive Update: The updates that are applied to database before it becomes
effective in real world.
2. Retroactive Update: The updates that are applied to database after it becomes
effective in real world.
3. Simulatneous Update: The updates that are applied to database at the same time
when it becomes effective in real world.
SQL QUESTIONS:
1. What is DBMS ?
The database management system is a collection of programs that enables user to store, retrieve,
update and delete information from a database.

2. What is RDBMS ?

Relational Database Management system (RDBMS) is a database management system (DBMS)


that is based on the relational model. Data from relational database can be accessed or
reassembled in many different ways without having to reorganize the database tables. Data from
relational database can be accessed using an API , Structured Query Language (SQL).

3. What is SQL ?

Structured Query Language(SQL) is a language designed specifically for communicating with


databases. SQL is an ANSI (American National Standards Institute) standard.
4. What are the different type of SQL's statements ?
This is one of the most frequently asked SQL Interview Questions for freshers. SQL statements
are broadly classified into three. They are
1. DDL – Data Definition Language
DDL is used to define the structure that holds the data. For example, Create, Alter, Drop and
Truncate table.
2. DML– Data Manipulation Language
DML is used for manipulation of the data itself. Typical operations are Insert, Delete, Update
and retrieving the data from the table. The Select statement is considered as a limited version of
the DML, since it can't change the data in the database. But it can perform operations on data
retrieved from the DBMS, before the results are returned to the calling function.
3. DCL– Data Control Language
DCL is used to control the visibility of data like granting database access and set privileges to
create tables, etc. Example - Grant, Revoke access permission to the user to access data in the
database.
5. What are the Advantages of SQL ?
1. SQL is not a proprietary language used by specific database vendors. Almost every major
DBMS supports SQL, so learning this one language will enable programmers to interact with
any database like ORACLE, SQL ,MYSQL etc.
2. SQL is easy to learn. The statements are all made up of descriptive English words, and there
aren't that many of them.
3. SQL is actually a very powerful language and by using its language elements you can perform
very complex and sophisticated database operations.
6. what is a field in a database ?

A field is an area within a record reserved for a specific piece of data.


Examples: Employee Name, Employee ID, etc.
Must Read - Top 100+ SQL Query Interview Questions and Answers and SQL Tutorial
7.What is a Record in a database ?

A record is the collection of values / fields of a specific entity: i.e. an Employee, Salary etc.

8. What is a Table in a database ?

A table is a collection of records of a specific type. For example, employee table, salary table etc.
9. What is a database transaction?

Database transaction takes database from one consistent state to another. At the end of the
transaction the system must be in the prior state if the transaction fails or the status of the system
should reflect the successful completion if the transaction goes through.

10. What are properties of a transaction?


Expect this SQL Interview Questions as a part of an any interview, irrespective of your
experience. Properties of the transaction can be summarized as ACID Properties.
1. Atomicity
A transaction consists of many steps. When all the steps in a transaction get completed, it will
get reflected in DB or if any step fails, all the transactions are rolled back.

2. Consistency
The database will move from one consistent state to another, if the transaction succeeds and
remain in the original state, if the transaction fails.

3. Isolation
Every transaction should operate as if it is the only transaction in the system.

4. Durability
Once a transaction has completed successfully, the updated rows/records must be available for
all other transactions on a permanent basis.

11. What is a Database Lock ?

Database lock tells a transaction, if the data item in questions is currently being used by other
transactions.
12. What are the type of locks ?

1. Shared Lock
When a shared lock is applied on data item, other transactions can only read the item, but can't
write into it.

2. Exclusive Lock
When an exclusive lock is applied on data item, other transactions can't read or write into the
data item.
Database Normalization Interview Questions

13. What are the different type of normalization?

In database design, we start with one single table, with all possible columns. A lot of redundant
data would be present since it’s a single table. The process of removing the redundant data, by
splitting up the table in a well defined fashion is called normalization.

1. First Normal Form (1NF)


A relation is said to be in first normal form if and only if all underlying domains contain atomic
values only. After 1NF, we can still have redundant data.

2. Second Normal Form (2NF)


A relation is said to be in 2NF if and only if it is in 1NF and every non key attribute is fully
dependent on the primary key. After 2NF, we can still have redundant data.

3. Third Normal Form (3NF)


A relation is said to be in 3NF, if and only if it is in 2NF and every non key attribute is non-
transitively dependent on the primary key.
Database Keys and Constraints SQL Interview Questions

14. What is a primary key?

A primary key is a column whose values uniquely identify every row in a table. Primary key
values can never be reused. If a row is deleted from the table, its primary key may not be
assigned to any new rows in the future. To define a field as primary key, following conditions
had to be met :

1. No two rows can have the same primary key value.


2. Every row must have a primary key value.
3. The primary key field cannot be null.
4. Value in a primary key column can never be modified or updated, if any foreign key refers to
that primary key.
15. What is a Composite Key ?

A Composite primary key is a type of candidate key, which represents a set of columns whose
values uniquely identify every row in a table.

For example - if "Employee_ID" and "Employee Name" in a table is combined to uniquely


identify a row its called a Composite Key.
16. What is a Composite Primary Key ?
A Composite primary key is a set of columns whose values uniquely identify every row in a
table. What it means is that, a table which contains composite primary key will be indexed based
on the columns specified in the primary key. This key will be referred in Foreign Key tables.

For example - if the combined effect of columns, "Employee_ID" and "Employee Name" in a
table is required to uniquely identify a row, its called a Composite Primary Key. In this case,
both the columns will be represented as primary key.
17. What is a Foreign Key ?

When a "one" table's primary key field is added to a related "many" table in order to create the
common field which relates the two tables, it is called a foreign key in the "many" table.

For example, the salary of an employee is stored in salary table. The relation is established via
foreign key column “Employee_ID_Ref” which refers “Employee_ID” field in the Employee
table.
18. What is a Unique Key ?

Unique key is same as primary with the difference being the existence of null. Unique key field
allows one value as NULL value.
SQL Insert, Update and Delete Commands Interview Questions

19. Define SQL Insert Statement ?

SQL INSERT statement is used to add rows to a table. For a full row insert, SQL Query should
start with “insert into “ statement followed by table name and values command, followed by the
values that need to be inserted into the table. The insert can be used in several ways:

1. To insert a single complete row.


2. To insert a single partial row.

20. Define SQL Update Statement ?

SQL Update is used to update data in a row or set of rows specified in the filter condition.

The basic format of an SQL UPDATE statement is, Update command followed by table to be
updated and SET command followed by column names and their new values followed by filter
condition that determines which rows should be updated.

21. Define SQL Delete Statement ?

SQL Delete is used to delete a row or set of rows specified in the filter condition.
The basic format of an SQL DELETE statement is, DELETE FROM command followed by
table name followed by filter condition that determines which rows should be updated.
22. What are wild cards used in database for Pattern Matching ?

SQL Like operator is used for pattern matching. SQL 'Like' command takes more time to
process. So before using "like" operator, consider suggestions given below on when and where to
use wild card search.

1) Don't overuse wild cards. If another search operator will do, use it instead.
2) When you do use wild cards, try not to use them at the beginning of the search pattern, unless
absolutely necessary. Search patterns that begin with wild cards are the slowest to process.
3) Pay careful attention to the placement of the wild card symbols. If they are misplaced, you
might not return the data you intended.

SQL Joins Interview Questions and answers

23. Define Join and explain different type of joins?


Another frequently asked SQL Interview Questions on Joins. In order to avoid data duplication,
data is stored in related tables. Join keyword is used to fetch data from related tables. "Join"
return rows when there is at least one match in both table. Type of joins are

Right Join
Return all rows from the right table, even if there are no matches in the left table.

Outer Join

Left Join
Return all rows from the left table, even if there are no matches in the right table.

Full Join
Return rows when there is a match in one of the tables.
24. What is Self-Join?

Self-join is query used to join a table to itself. Aliases should be used for the same table
comparison.

25. What is Cross Join?

Cross Join will return all records where each row from the first table is combined with each row
from the second table.
Database Views Interview Questions

26. What is a view?

The views are virtual tables. Unlike tables that contain data, views simply contain queries that
dynamically retrieve data when used.
27. What is a materialized view?

Materialized views are also a view but are disk based. Materialized views get updates on specific
duration, base upon the interval specified in the query definition. We can index materialized
view.

28. What are the advantages and disadvantages of views in a database?

Advantages:
1. Views don't store data in a physical location.
2. The view can be used to hide some of the columns from the table.
3. Views can provide Access Restriction, since data insertion, update and deletion is not possible
with the view.

Disadvantages:
1. When a table is dropped, associated view become irrelevant.
2. Since the view is created when a query requesting data from view is triggered, its a bit slow.
3. When views are created for large tables, it occupies more memory.
29. What is a stored procedure?

Stored Procedure is a function which contains a collection of SQL Queries. The procedure can
take inputs , process them and send back output.

30. What are the advantages of a stored procedure?


Stored Procedures are precomplied and stored in the database. This enables the database to
execute the queries much faster. Since many queries can be included in a stored procedure, round
trip time to execute multiple queries from source code to database and back is avoided.

31. What is a trigger?

Database triggers are sets of commands that get executed when an event(Before Insert, After
Insert, On Update, On delete of a row) occurs on a table, views.

32. Explain the difference between DELETE , TRUNCATE and DROP commands?

Once delete operation is performed, Commit and Rollback can be performed to retrieve data.

Once the truncate statement is executed, Commit and Rollback statement cannot be performed.
Where condition can be used along with delete statement but it can't be used with truncate
statement.

Drop command is used to drop the table or keys like primary,foreign from a table.

33. What is the difference between Cluster and Non cluster Index?
A clustered index reorders the way records in the table are physically stored. There can be only
one clustered index per table. It makes data retrieval faster.

A non clustered index does not alter the way it was stored but creates a completely separate
object within the table. As a result insert and update command will be faster.

34. What is Union, minus and Interact commands?

MINUS operator is used to return rows from the first query but not from the second query.
INTERSECT operator is used to return rows returned by both the queries.
Freshers world

1. What is database?

A database is a collection of information that is organized. So that it can easily be accessed,


managed, and updated.

2. What is DBMS?

DBMS stands for Database Management System. It is a collection of programs that enables user
to create and maintain a database.

3. What is a Database system?

The database and DBMS software together is called as Database system.

4. What are the advantages of DBMS?

I. Redundancy is controlled.

II. Providing multiple user interfaces.

III. Providing backup and recovery

IV. Unauthorized access is restricted.

V. Enforcing integrity constraints.


5. What is normalization?

It is a process of analysing the given relation schemas based on their Functional Dependencies
(FDs) and primary key to achieve the properties
(1).Minimizing redundancy, (2). Minimizing insertion, deletion and update anomalies.

6. What is Data Model?


A collection of conceptual tools for describing data, data relationships data semantics and
constraints.

7. 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.

8. 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.

9. What is an Entity?
An entity is a thing or object of importance about which data must be captured.

10. What is DDL (Data Definition Language)?

A data base schema is specifies by a set of definitions expressed by a special language called
DDL.

11. What is DML (Data Manipulation Language)?

This language that enable user to access or manipulate data as organised by appropriate data
model. Procedural DML or Low level: DML requires a user to specify what data are needed and
how to get those data. Non-Procedural DML or High level: DML requires a user to specify what
data are needed without specifying how to get those data

12. What is DML Compiler?

It translates DML statements in a query language into low-level instruction that the query
evaluation engine can understand.

13. What is Query evaluation engine?

It executes low-level instruction generated by compiler.

14. What is Functional Dependency?

Functional Dependency is the starting point of normalization. Functional Dependency exists


when a relation between two attributes allows you to uniquely determine the corresponding
attribute’s value.

15. What is 1 NF (Normal Form)?

The first normal form or 1NF is the first and the simplest type of normalization that can be
implemented in a database. The main aims of 1NF are to:

1. Eliminate duplicative columns from the same table.

2. Create separate tables for each group of related data and identify each row with a unique
column (the primary key).

16. What is Fully 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.

17. 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.

18. What is 3NF?

A relation is in third normal form if it is in Second Normal Form and there are no functional
(transitive) dependencies between two (or more) non-primary key attributes.

19. What is BCNF (Boyce-Codd Normal Form)?

A table is in Boyce-Codd normal form (BCNF) if and only if it is in 3NF and every determinant
is a candidate key.

20. What is 4NF?

Fourth normal form requires that a table be BCNF and contain no multi-valued dependencies.

21. What is 5NF?

A table is in fifth normal form (5NF) or Project-Join Normal Form (PJNF) if it is in 4NF and it
cannot have a lossless decomposition into any number of smaller tables.

22. What is a query?

A query with respect to DBMS relates to user commands that are used to interact with a data
base.

23. 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.
24. What is an attribute?
It is a particular property, which describes the entity.

25. What is RDBMS?

Relational Data Base Management Systems (RDBMS) are database management systems that
maintain data records and indices in tables.

26. What’s difference between DBMS and RDBMS?

DBMS provides a systematic and organized way of storing, managing and retrieving from
collection of logically related information. RDBMS also provides what DBMS provides but
above that it provides relationship integrity.

27. What is SQL?

SQL stands for Structured Query Language. SQL is an ANSI (American National Standards
Institute) standard computer language for accessing and manipulating database systems. SQL
statements are used to retrieve and update data in a database.

28. What is Stored Procedure?

A stored procedure is a named group of SQL statements that have been previously created and
stored in the server database.

29. What is a view?

A view may be a subset of the database or it may contain virtual data that is derived from the
database files but is not explicitly stored.

30. What is Trigger?

A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or
UPDATE) occurs.
31. What is Index?

An index is a physical structure containing pointers to the data.

32. What is extension and intension?

Extension -It is the number of tuples present in a table at any instance. This is time dependent.

Intension -It is a constant value that gives the name, structure of table and the constraints laid on
it.

33. What do you mean by atomicity and aggregation?

Atomicity-Atomicity states that database modifications must follow an “all or nothing” rule.
Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction
fails.

Aggregation - A feature of the entity relationship model that allows a relationship set to
participate in another relationship set. This is indicated on an ER diagram by drawing a dashed
box around the aggregation.

34. What is RDBMS KERNEL?

Two important pieces of RDBMS architecture are the kernel, which is the software, and the data
dictionary, which consists of the system- level data structures used by the kernel to manage the
database.

35. Name the sub-systems of a RDBMS?

I/O, Security, Language Processing, Process Control, Storage Management, Logging and
Recovery, Distribution Control, Transaction Control, Memory Management, Lock Management.

36. How do you communicate with an RDBMS?


You communicate with an RDBMS using Structured Query Language (SQL)

37. Disadvantage in File Processing System?

· Data redundancy & inconsistency.

· Difficult in accessing data.

· Data isolation.

· Data integrity.

· Concurrent access is not possible.

· Security Problems.

38. What is VDL (View Definition Language)?

It specifies user views and their mappings to the conceptual schema.

39. What is SDL (Storage Definition Language)?

This language is to specify the internal schema. This language may Specify the mapping between
two schemas.

40. Describe concurrency control?

Concurrency control is the process managing simultaneous operations against a database so that
database integrity is no compromised. There are two approaches to concurrency control.

The pessimistic approach involves locking and the optimistic approach involves versioning.

41. Describe the difference between homogeneous and heterogeneous distributed database?

A homogenous database is one that uses the same DBMS at each node. A heterogeneous
database is one that may have a different DBMS at each node.
42. What is a distributed database?

A distributed database is a single logical database that is spread across more than one node or
locations that are all connected via some communication link.

43. Explain the difference between two and three-tier architectures?

Three-tier architecture includes a client and two server layers.

The application code is stored on the application server and the database is stored on the
database server. A two-tier architecture includes a client and one server layer. The database is
stored on the database server.

44. Briefly describe the three types of SQL commands?

Data definition language commands are used to create, alter, and drop tables. Data manipulation
commands are used to insert, modify, update, and query data in the database. Data control
language commands help the DBA to control the database.

45. List some of the properties of a relation?

Relations in a database have a unique name and no multivalued attributes exist. Each row is
unique and each attribute within a relation has a unique name. The sequence of both columns and
rows is irrelevant.

46. Explain the differences between an intranet and an extranet?

An Internet database is accessible by everyone who has access to a Web site. An intranet
database limits access to only people within a given organization.

47. What is SQL Deadlock?

Deadlock is a unique situation in a multi user system that causes two or more users to wait
indefinitely for a locked resource.
48. What is a Catalog?

A catalog is a table that contains the information such as structure of each file, the type and
storage format of each data item and various constraints on the data .The information stored in
the catalog is called Metadata.

49. What is data ware housing & OLAP?

Data warehousing and OLAP (online analytical processing) systems are the techniques used in
many companies to extract and analyze useful information from very large databases for
decision making .

50. Describe the three levels of data abstraction?

Physical level: The lowest level of abstraction describes how data are stored.

Logical level: The next higher level of abstraction, describes what data are stored in database and
what relationship among those data.

View level: The highest level of abstraction describes only part of entire database.

51. What is Data Independence?

Data independence means that the application is independent of the storage structure and access
strategy of data.

52. How many types of relationship exist in database designing?

There are three major relationship models:-

One-to-one

One-to-many

Many-to-many
53. What is order by clause?

ORDER BY clause helps to sort the data in either ascending order to descending

54. What is the use of DBCC commands?

DBCC stands for database consistency checker. We use these commands to check the
consistency of the databases, i.e., maintenance, validation task and status checks.

55. What is Collation?

Collation refers to a set of rules that determine how data is sorted and compared.

56. What is difference between DELETE & TRUNCATE commands?

Delete command removes the rows from a table based on the condition that we provide with a
WHERE clause. Truncate will actually remove all the rows from a table and there will be no data
in the table after we run the truncate command.

57. What is Hashing technique?

This is a primary file organization technique that provides very fast access to records on certain
search conditions.

58. What is a transaction?

A transaction is a logical unit of database processing that includes one or more database access
operations.

59. What are the different phases of Transaction?

Analysis phase
Redo phase

Undo phase

60. What is “transparent dbms”?

It is one, which keeps its physical structure hidden from user.

61. What are the primitive operations common to all record management System?

Addition, deletion and modification.

62. Explain the differences between structured data and unstructured data.

Structured data are facts concerning objects and events. The most important structured data are
numeric, character, and dates.

Structured data are stored in tabular form. Unstructured data are multimedia data such as
documents, photographs, maps, images, sound, and video clips. Unstructured data are most
commonly found on Web servers and Web-enabled databases.

63. What are the major functions of the database administrator?

Managing database structure, controlling concurrent processing, managing processing rights and
responsibilities, developing database security, providing for database recovery, managing the
DBMS and maintaining the data repository.

64. What is a dependency graph?

A dependency graph is a diagram that is used to portray the connections between database
elements.

65. Explain the difference between an exclusive lock and a shared lock?
An exclusive lock prohibits other users from reading the locked resource; a shared lock allows
other users to read the locked resource, but they cannot update it.

66. Explain the "paradigm mismatch" between SQL and application programming languages.

SQL statements return a set of rows, while an application program works on one row at a time.
To resolve this mismatch the results of SQL statements are processed as pseudofiles, using a
cursor or pointer to specify which row is being processed.

67. Name four applications for triggers.

(1)Providing default values, (2) enforcing data constraints,

(3) Updating views and (4) enforcing referential integrity

68. What are the advantages of using stored procedures?

The advantages of stored procedures are (1) greater security, (2) decreased network traffic, (3)
the fact that SQL can be optimized and (4) code sharing which leads to less work, standardized
processing, and specialization among developers.

69. Explain the difference between attributes and identifiers.

Entities have attributes. Attributes are properties that describe the entity's characteristics. Entity
instances have identifiers. Identifiers are attributes that name, or identify, entity instances.

70. What is Enterprise Resource Planning (ERP), and what kind of a database is used in an ERP
application?

Enterprise Resource Planning (ERP) is an information system used in manufacturing companies


and includes sales, inventory, production planning, purchasing and other business functions. An
ERP system typically uses a multiuser database.

71. Describe the difference between embedded and dynamic SQL?


Embedded SQL is the process of including hard coded SQL statements. These statements do not
change unless the source code is modified. Dynamic SQL is the process of generating SQL on
the fly.The statements generated do not have to be the same each time.

72. Explain a join between tables

A join allows tables to be linked to other tables when a relationship between the tables exists.
The relationships are established by using a common column in the tables and often uses the
primary/foreign key relationship.

73. Describe a subquery.

A subquery is a query that is composed of two queries. The first query (inner query) is within the
WHERE clause of the other query (outer query).

74. Compare a hierarchical and network database model?

The hierarchical model is a top-down structure where each parent may have many children but
each child can have only one parent. This model supports one-to-one and one-to-many
relationships.

The network model can be much more flexible than the hierarchical model since each parent can
have multiple children but each child can also have multiple parents. This model supports one-
to-one, one-to-many, and many-to-many relationships.

75. Explain the difference between a dynamic and materialized view.

A dynamic view may be created every time that a specific view is requested by a user. A
materialized view is created and or updated infrequently and it must be synchronized with its
associated base table(s)

76. Explain what needs to happen to convert a relation to third normal form.

First you must verify that a relation is in both first normal form and second normal form. If the
relation is not, you must convert into second normal form. After a relation is in second normal
form, you must remove all transitive dependencies.
77. Describe the four types of indexes?

A unique primary index is unique and is used to find and store a row. A nonunique primary
index is not unique and is used to find a row but also where to store a row (based on its unique
primary index). A unique secondary index is unique for each row and used to find table rows. A
nonunique secondary index is not unique and used to find table rows.

78. Explain minimum and maximum cardinality?

Minimum cardinality is the minimum number of instances of an entity that can be associated
with each instance of another entity. Maximum cardinality is the maximum number of instances
of an entity that can be associated with each instance of another entity.

79. What is deadlock? How can it be avoided? How can it be resolved once it occurs?

Deadlock occurs when two transactions are each waiting on a resource that the other transaction
holds. Deadlock can be prevented by requiring transactions to acquire all locks at the same time;
once it occurs, the only way to cure it is to abort one of the transactions and back out of partially
completed work.

80. Explain what we mean by an ACID transaction.

An ACID transaction is one that is atomic, consistent, isolated, and durable. Durable means that
database changes are permanent. Consistency can mean either statement level or transaction
level consistency. With transaction level consistency, a transaction may not see its own
changes.Atomic means it is performed as a unit.

81. Under what conditions should indexes be used?

Indexes can be created to enforce uniqueness, to facilitate sorting, and to enable fast retrieval by
column values. A good candidate for an index is a column that is frequently used with equal
conditions in WHERE clauses.

82. What is difference between SQL and SQL SERVER?


SQL is a language that provides an interface to RDBMS, developed by IBM. SQL SERVER is a
RDBMS just like Oracle, DB2.

83. What is Specialization?

It is the process of defining a set of subclasses of an entity type where each subclass contain all
the attributes and relationships of the parent entity and may have additional attributes and
relationships which are specific to itself.

84. What is generalization?

It is the process of finding common attributes and relations of a number of entities and defining a
common super class for them.

85. What is meant by Proactive, Retroactive and Simultaneous Update?

Proactive Update: The updates that are applied to database before it becomes effective in real
world.

Retroactive Update: The updates that are applied to database after it becomes effective in real
world.

Simultaneous Update: The updates that are applied to database at the same time when it becomes
effective in real world.

86. What is RAID Technology?

Redundant array of inexpensive (or independent) disks. The main goal of raid technology is to
even out the widely different rates of performance improvement of disks against those in
memory and microprocessor. Raid technology employs the technique of data striping to achieve
higher transfer rates.

87. What are serial, non serial schedule?


A schedule S is serial if, for every transaction T participating in the schedule, all the operations
of T is executed consecutively in the schedule, otherwise, the schedule is called non-serial
schedule.

88. What are conflict serializable schedules?

A schedule S of n transactions is serializable if it is equivalent to some serial schedule of the


same n transactions.

89. What is view serializable?

A schedule is said to be view serializable if it is view equivalent with some serial schedule.

90. What is a foreign key?

A key of a relation schema is called as a foreign key if it is the primary key of


some other relation to which it is related to.

91. What are the disadvantages of using a dbms?

1) High initial investments in h/w, s/w, and training.


2) Generality that a DBMS provides for defining and processing data.
3) Overhead for providing security, concurrency control, recovery, and integrity functions.

92. What is Lossless join property?


It guarantees that the spurious tuple generation does not occur with respect to relation schemas
after decomposition.

93. What is a Phantom Deadlock?


In distributed deadlock detection, the delay in propagating local information might cause the
deadlock detection algorithms to identify deadlocks that do not really exist. Such situations are
called phantom deadlocks and they lead to unnecessary aborts.
94. What is a checkpoint and When does it occur?
A Checkpoint is like a snapshot of the DBMS state. By taking checkpoints, the DBMS can
reduce the amount of work to be done during restart in the event of subsequent crashes.

95. What is schema?


The description of a data base is called the database schema , which is specified during database
design and is not expected to change frequently . A displayed schema is called schema diagram
.We call each object in the schema as schema construct.

SQL Advanced
17513
1.What is REDO in database?

A. Opposite of UNDO
B. Re-does the previous operation on database again.
C. REDO is used for ROLLBACK.
D. None of the above.
Answer: C
The most important point to remember is REDO is not the opposite of UNDO. Whenever a DML
transaction happens in database, the data to be updated goes to the DATABASE BUFFER
CACHE. From here the data is written to REDO BUFFER and then to REDO Logs. These logs
are saved for future use. Future ROLLBACK and DATA RECOVERY operations require these
logs. Without these logs it is impossible to do DATA RECOVERY. If ARCHIVING is enabled
then these logs are bundled or archived and stored.

2. COMMIT takes more time than ROLLBACK .

A. True
B. False
Answer: B
COMMIT simply confirms the transaction and writes the committed data to disk and clears
UNDO file. While ROLLBACK does the opposite transaction. ROLLBACK also clears UNDO
file. ROLLBACK takes much longer time because it has to execute one full transaction
(opposite) and COMMIT it. Hence COMMIT is faster than ROLLBACK.
3. What is the difference between ORDERBY and GROUPBY?

A. ORDERBY performs sorting while GROUPBY AGGREGATES Data

B. GROUPBY sorts data while ORDERBY puts data in order


C. Both perform sorting.
D. None of the above
Answer: A
The ORDER BY performs a sort operation. So think of a telephone phone directory.
SELECT NAME FROM DIRECTORY ORDER BY NAME
This would ensure that the result set would be sorted in (by default) ascending order.
The GROUP BY operation aggregates data in your result set. Continuing the example of the
telephone directory
SELECT CITY, COUNT(CITY) FROM DIRECTORY GROUP BY CITY
This would ensure that the result set would be grouped according to the city where the individual
lives. The COUNT and GROUP BY works in conjunction.

4. Which of the following records all modifications to data?

A. UNDO file
B. Alert Log file
C. Archive file
D. Both A & B
Answer: C
Alert log file records all modifications to the database but modifications to data alone is recorded
by Archive files. UNDO file stores UNDO tables which have opposite transactions recorded.
Archive files also help in recovery of data.

5. Which is better ?

A. SQL
B. Procedures
Answer: SQL
• SQL is often much shorter to write - you can do an update or summary procedure in one line of
code that would take you several lines of procedural.
• For set-based problems - SQL is much faster processor-wise and IO wise too because all the
underlining looping iteration is delegated to a database server process that does it in a very low
level way and uses IO/processor more efficiently and knows the current state of the data - e.g.
what other processes are asking for the data
If you were to update say a sales person of all customers in a particular region - your procedural
way would look something like this
do until eof
if rs("state") = "NH" then
rs("salesperson") = "Mike"
end if
rs.next
loop
The SQL way would be: UPDATE customers SET salesperson = "Mike" WHERE state = "NH"
If you had, say 2 or 3 tables you need to check, your procedural quickly becomes difficult to
manage as you pile on nested loop after loop.

Database (DBMS) interview questions and answers are below


Questions What is database or database management systems (DBMS)? and - What’s the
:1 difference between file and database? Can files qualify as a database?

Answers Database provides a systematic and organized way of storing, managing and
:1 retrieving from collection of logically related information.

Secondly the information has to be persistent, that means even after the application is
closed the information should be persisted.

Finally it should provide an independent way of accessing data and should not be
dependent on the application to access the information.

Main difference between a simple file and database that database has independent
way (SQL) of accessing information while simple files do not File meets the storing,
managing and retrieving part of a database but not the independent way of accessing
data. Many experienced programmers think that the main difference is that file can
not provide multi-user capabilities which a DBMS provides. But if we look at some
old COBOL and C programs where file where the only means of storing data, we can
see functionalities like locking, multi-user etc provided very efficiently. So it’s a
matter of debate if some interviewers think this as a main difference between files
and database accept it… going in to debate is probably loosing a job.

Questions
What is SQL ?
:2

Answers SQL stands for Structured Query Language.SQL is an ANSI (American National
:2 Standards Institute) standard computer language for accessing and manipulating
database systems. SQL statements are used to retrieve and update data in a database.

Questions
What’s difference between DBMS and RDBMS ?
:3

Answers DBMS provides a systematic and organized way of storing, managing and retrieving
:3 from collection of logically related information. RDBMS also provides what DBMS
provides but above that it provides relationship integrity. So in short we can say
RDBMS = DBMS + REFERENTIAL INTEGRITY
These relations are defined by using “Foreign Keys” in any RDBMS.Many DBMS
companies claimed there DBMS product was a RDBMS compliant, but according to
industry rules and regulations if the DBMS fulfills the twelve CODD rules it’s truly a
RDBMS. Almost all DBMS (SQL SERVER, ORACLE etc) fulfills all the twelve
CODD rules and are considered as truly RDBMS.

Questions
What are CODD rules?
:4

Answers In 1969 Dr. E. F. Codd laid down some 12 rules which a DBMS should adhere in
:4 order to get the logo of a true RDBMS.

Rule 1: Information Rule.


"All information in a relational data base is represented explicitly at the logical level
and in exactly one way - by values in tables."
Rule 2: Guaranteed access Rule.
"Each and every datum (atomic value) in a relational data base is guaranteed to be
logically accessible by resorting to a combination of table name, primary key value
and column name."
In flat files we have to parse and know exact location of field values. But if a DBMS
is truly RDBMS you can access the value by specifying the table name, field name,
for instance Customers.Fields [‘Customer Name’].
Rule 3: Systematic treatment of null values.
"Null values (distinct from the empty character string or a string of blank characters
and distinct from zero or any other number) are supported in fully relational DBMS
for representing missing information and inapplicable information in a systematic
way, independent of data type.".
Rule 4: Dynamic on-line catalog based on the relational model.
"The data base description is represented at the logical level in the same way as
ordinary data, so that authorized users can apply the same relational language to its
interrogation as they apply to the regular data."The Data Dictionary is held within the
RDBMS, thus there is no-need for off-line volumes to tell you the structure of the
database.
Rule 5: Comprehensive data sub-language Rule.
"A relational system may support several languages and various modes of terminal
use (for example, the fill-in-the-blanks mode). However, there must be at least one
language whose statements are expressible, per some well-defined syntax, as
character strings and that is comprehensive in supporting all the following items

Data Definition
View Definition
Data Manipulation (Interactive and by program).
Integrity Constraints
Authorization.
Transaction boundaries ( Begin , commit and rollback)
Rule 6: .View updating Rule
"All views that are theoretically updatable are also updatable by the system."
Rule 7: High-level insert, update and delete.
"The capability of handling a base relation or a derived relation as a single operand
applies not only to the retrieval of data but also to the insertion, update and deletion
of data."
Rule 8: Physical data independence.
"Application programs and terminal activities remain logically unimpaired whenever
any changes are made in either storage representations or access methods."
Rule 9: Logical data independence.
"Application programs and terminal activities remain logically unimpaired when
information-preserving changes of any kind that theoretically permit un-impairment
are made to the base tables."
Rule 10: Integrity independence.
"Integrity constraints specific to a particular relational data base must be definable in
the relational data sub-language and storable in the catalog, not in the application
programs." Rule 11: Distribution independence.
"A relational DBMS has distribution independence."
Rule 12: Non-subversion Rule.
"If a relational system has a low-level (single-record-at-a-time) language, that low
level cannot be used to subvert or bypass the integrity Rules and constraints
expressed in the higher level relational language (multiple-records-at-a-time)."

Questions
What are E-R diagrams?
:5

Answers E-R diagram also termed as Entity-Relationship diagram shows relationship between
:5 various tables in the database. .
Questions
How many types of relationship exist in database designing?
:6

Answers There are three major relationship models:-


:6 One-to-one
One-to-many
Many-to-many

Questions
7.What is normalization? What are different type of normalization?
:7

Answers There is set of rules that has been established to aid in the design of tables that are
:7 meant to be connected through relationships. This set of rules is known as
Normalization.
Benefits of Normalizing your database include:
=>Avoiding repetitive entries
=>Reducing required storage space
=>Preventing the need to restructure existing tables to accommodate new data.
=>Increased speed and flexibility of queries, sorts, and summaries.

Following are the three normal forms :-


First Normal Form
For a table to be in first normal form, data must be broken up into the smallest un
possible.In addition to breaking data up into the smallest meaningful values, tables
first normal form should not contain repetitions groups of fields.
Second Normal form
The second normal form states that each field in a multiple field primary keytable
must be directly related to the entire primary key. Or in other words,each non-key
field should be a fact about all the fields in the primary key.
Third normal form
A non-key field should not depend on other Non-key field.

Questions
What is denormalization ?
:8

Answers Denormalization is the process of putting one fact in numerous places (its vice-versa
:8 of normalization).Only one valid reason exists for denormalizing a relational design -
to enhance performance.The sacrifice to performance is that you increase redundancy
in database.

Questions Can you explain Fourth Normal Form and Fifth Normal Form ?
:9

Answers In fourth normal form it should not contain two or more independent multi-v about an
:9 entity and it should satisfy “Third Normal form”.
Fifth normal form deals with reconstructing information from smaller pieces of
information. These smaller pieces of information can be maintained with less
redundancy.

Questions
Have you heard about sixth normal form?
: 10

Answers If we want relational system in conjunction with time we use sixth normal form. At
: 10 this moment SQL Server does not supports it directly.

Questions
What are DML and DDL statements?
: 11

Answers DML stands for Data Manipulation Statements. They update data values in table.
: 11 Below are the most important DDL statements:-
=>SELECT - gets data from a database table
=> UPDATE - updates data in a table
=> DELETE - deletes data from a database table
=> INSERT INTO - inserts new data into a database table

DDL stands for Data definition Language. They change structure of the database
objects like table, index etc. Most important DDL statements are as shown below:-
=>CREATE TABLE - creates a new table in the database.
=>ALTER TABLE – changes table structure in database.
=>DROP TABLE - deletes a table from database
=> CREATE INDEX - creates an index
=> DROP INDEX - deletes an index

Questions
How do we select distinct values from a table?
: 12

Answers DISTINCT keyword is used to return only distinct values. Below is syntax:- Column
: 12 age and Table pcdsEmp
SELECT DISTINCT age FROM pcdsEmp
Questions
What is Like operator for and what are wild cards?
: 13

Answers LIKE operator is used to match patterns. A "%" sign is used to define the pattern.
: 13 Below SQL statement will return all words with letter "S"
SELECT * FROM pcdsEmployee WHERE EmpName LIKE 'S%'
Below SQL statement will return all words which end with letter "S"
SELECT * FROM pcdsEmployee WHERE EmpName LIKE '%S'
Below SQL statement will return all words having letter "S" in between
SELECT * FROM pcdsEmployee WHERE EmpName LIKE '%S%'
"_" operator (we can read as “Underscore Operator”). “_” operator is the character
defined at that point. In the below sample fired a query Select name from
pcdsEmployee where name like '_s%' So all name where second letter is “s” is
returned.

Questions
Can you explain Insert, Update and Delete query?
: 14

Answers Insert statement is used to insert new rows in to table. Update to update existing data
: 14 in the table. Delete statement to delete a record from the table. Below code snippet
for Insert, Update and Delete :-

INSERT INTO pcdsEmployee SET name='rohit',age='24';


UPDATE pcdsEmployee SET age='25' where name='rohit';
DELETE FROM pcdsEmployee WHERE name = 'sonia';

Questions
What is order by clause?
: 15

Answers ORDER BY clause helps to sort the data in either ascending order to descending
: 15 order.
Ascending order sort query
SELECT name,age FROM pcdsEmployee ORDER BY age ASC
Descending order sort query
SELECT name FROM pcdsEmployee ORDER BY age DESC

Questions
What is the SQL " IN " clause?
: 16

Answers SQL IN operator is used to see if the value exists in a group of values. For instance
the below SQL checks if the Name is either 'rohit' or 'Anuradha' SELECT * FROM
: 16 pcdsEmployee WHERE name IN ('Rohit','Anuradha') Also you can specify a not
clause with the same. SELECT * FROM pcdsEmployee WHERE age NOT IN
(17,16)

Questions
Can you explain the between clause?
: 17

Answers Below SQL selects employees born between '01/01/1975' AND '01/01/1978' as per
: 17 mysql
SELECT * FROM pcdsEmployee WHERE DOB BETWEEN '1975-01-01' AND
'2011-09-28'

Questions
we have an employee salary table how do we find the second highest from it?
: 18

Answers below Sql Query find the second highest salary


: 18 SELECT * FROM pcdsEmployeeSalary a WHERE (2=(SELECT
COUNT(DISTINCT(b.salary)) FROM pcdsEmployeeSalary b WHERE
b.salary>=a.salary))

Questions
What are different types of joins in SQL?
: 19

Answers INNER JOIN


: 19 Inner join shows matches only when they exist in both tables. Example in the below
SQL there are two tables Customers and Orders and the inner join in made on
Customers.Customerid and Orders.Customerid. So this SQL will only give you result
with customers who have orders. If the customer does not have order it will not
display that record.
SELECT Customers.*, Orders.* FROM Customers INNER JOIN Orders ON
Customers.CustomerID =Orders.CustomerID

LEFT OUTER JOIN


Left join will display all records in left table of the SQL statement. In SQL below
customers with or without orders will be displayed. Order data for customers without
orders appears as NULL values. For example, you want to determine the amount
ordered by each customer and you need to see who has not ordered anything as well.
You can also see the LEFT OUTER JOIN as a mirror image of the RIGHT OUTER
JOIN (Is covered in the next section) if you switch the side of each table.
SELECT Customers.*, Orders.* FROM Customers LEFT OUTER JOIN Orders ON
Customers.CustomerID =Orders.CustomerID

RIGHT OUTER JOIN


Right join will display all records in right table of the SQL statement. In SQL below
all orders with or without matching customer records will be displayed. Customer
data for orders without customers appears as NULL values. For example, you want to
determine if there are any orders in the data with undefined CustomerID values (say,
after a conversion or something like it). You can also see the RIGHT OUTER JOIN
as a mirror image of the LEFT OUTER JOIN if you switch the side of each table.
SELECT Customers.*, Orders.* FROM Customers RIGHT OUTER JOIN Orders
ON Customers.CustomerID =Orders.CustomerID

Questions
What is “CROSS JOIN”? or What is Cartesian product?
: 20

Answers “CROSS JOIN” or “CARTESIAN PRODUCT” combines all rows from both tables.
: 20 Number of rows will be product of the number of rows in each table. In real life
scenario I can not imagine where we will want to use a Cartesian product. But there
are scenarios where we would like permutation and combination probably Cartesian
would be the easiest way to achieve it.

Questions
How to select the first record in a given set of rows?
: 21

Answers
: 21 Select top 1 * from sales.salesperson

Questions
What is the default “-SORT ” order for a SQL?
: 22

Answers
: 22 ASCENDING

Questions
What is a self-join?
: 23

Answers
: 23 If we want to join two instances of the same table we can use self-join.
Questions
What’s the difference between DELETE and TRUNCATE ?
: 24

Answers Following are difference between them:


: 24 =>>DELETE TABLE syntax logs the deletes thus making the delete operations low.
TRUNCATE table does not log any information but it logs information about
deallocation of data page of the table. So TRUNCATE table is faster as compared to
delete table.
=>>DELETE table can have criteria while TRUNCATE can not.
=>> TRUNCATE table can not have triggers.

Questions
What’s the difference between “UNION” and “UNION ALL” ?
: 25

Answers UNION SQL syntax is used to select information from two tables. But it selects only
: 25 distinct records from both the table. , while UNION ALL selects all records from
both the tables.

Questions
What are cursors and what are the situations you will use them?
: 26

Answers SQL statements are good for set at a time operation. So it is good at handling set of
: 26 data. But there are scenarios where we want to update row depending on certain
criteria. we will loop through all rows and update data accordingly. There’s where
cursors come in to picture.

Questions
What is " Group by " clause?
: 27

Answers
: 27 “Group by” clause group similar data so that aggregate values can be derived.

Questions
What is the difference between “HAVING” and “WHERE” clause?
: 28

Answers “HAVING” clause is used to specify filtering criteria for “GROUP BY”, while
: 28 “WHERE” clause applies on normal SQL.
Questions
What is a Sub-Query?
: 29

Answers A query nested inside a SELECT statement is known as a subquery and is an


: 29 alternative to complex join statements. A subquery combines data from multiple
tables and returns results that are inserted into the WHERE condition of the main
query. A subquery is always enclosed within parentheses and returns a column. A
subquery can also be referred to as an inner query and the main query as an outer
query. JOIN gives better performance than a subquery when you have to check for
the existence of records.
For example, to retrieve all EmployeeID and CustomerID records from the ORDERS
table that have the EmployeeID greater than the average of the EmployeeID field,
you can create a nested query, as shown:
SELECT DISTINCT EmployeeID, CustomerID FROM ORDERS WHERE
EmployeeID > (SELECT AVG(EmployeeID) FROM ORDERS)

Questions
What are Aggregate and Scalar Functions?
: 30

Answers Aggregate and Scalar functions are in built function for counting and calculations.
: 30 Aggregate functions operate against a group of values but returns only one value.
AVG(column) :- Returns the average value of a column
COUNT(column) :- Returns the number of rows (without a NULL value) of a column
COUNT(*) :- Returns the number of selected rows
MAX(column) :- Returns the highest value of a column
MIN(column) :- Returns the lowest value of a column
Scalar functions operate against a single value and return value on basis of the single
value.
UCASE(c) :- Converts a field to upper case
LCASE(c) :- Converts a field to lower case
MID(c,start[,end]) :- Extract characters from a text field
LEN(c) :- Returns the length of a text

Questions
Can you explain the SELECT INTO Statement?
: 31

Answers SELECT INTO statement is used mostly to create backups. The below SQL backsup
: 31 the Employee table in to the EmployeeBackUp table. One point to be noted is that the
structure of pcdsEmployeeBackup and pcdsEmployee table should be same. SELECT
* INTO pcdsEmployeeBackup FROM pcdsEmployee
Questions
What is a View?
: 32

Answers View is a virtual table which is created on the basis of the result set returned by the
: 32 select statement.
CREATE VIEW [MyView] AS SELECT * from pcdsEmployee where LastName =
'singh'
In order to query the view
SELECT * FROM [MyView]

Questions
What is SQl injection ?
: 33

Answers It is a Form of attack on a database-driven Web site in which the attacker executes
: 33 unauthorized SQL commands by taking advantage of insecure code on a system
connected to the Internet, bypassing the firewall. SQL injection attacks are used to
steal information from a database from which the data would normally not be
available and/or to gain access to an organization’s host computers through the
computer that is hosting the database.
SQL injection attacks typically are easy to avoid by ensuring that a system has strong
input validation.
As name suggest we inject SQL which can be relatively dangerous for the database.
Example this is a simple SQL
SELECT email, passwd, login_id, full_name
FROM members WHERE email = 'x'
Now somebody does not put “x” as the input but puts “x ; DROP TABLE members;”.
So the actual SQL which will execute is :-
SELECT email, passwd, login_id, full_name FROM members WHERE email = 'x' ;
DROP TABLE members;
Think what will happen to your database.

Questions
What is Data Warehousing ?
: 34

Answers Data Warehousing is a process in which the data is stored and accessed from central
: 34 location and is meant to support some strategic decisions. Data Warehousing is not a
requirement for Data mining. But just makes your Data mining process more
efficient.

Data warehouse is a collection of integrated, subject-oriented databases designed to


support the decision-support functions (DSF), where each unit of data is relevant to
some moment in time.

Questions
What are Data Marts?
: 35

Answers Data Marts are smaller section of Data Warehouses. They help data warehouses
: 35 collect data. For example your company has lot of branches which are spanned across
the globe. Head-office of the company decides to collect data from all these branches
for anticipating market. So to achieve this IT department can setup data mart in all
branch offices and a central data warehouse where all data will finally reside.

Questions What are Fact tables and Dimension Tables ? What is Dimensional Modeling and
: 36 Star Schema Design

Answers When we design transactional database we always think in terms of normalizing


: 36 design to its least form. But when it comes to designing for Data warehouse we think
more in terms of denormalizing the database. Data warehousing databases are
designed using Dimensional Modeling. Dimensional Modeling uses the existing
relational database structure and builds on that.
There are two basic tables in dimensional modeling:-
Fact Tables.
Dimension Tables.
Fact tables are central tables in data warehousing. Fact tables have the actual
aggregate values which will be needed in a business process. While dimension tables
revolve around fact tables. They describe the attributes of the fact tables.

Questions What is Snow Flake Schema design in database? What’s the difference between Star
: 37 and Snow flake schema?

Answers Star schema is good when you do not have big tables in data warehousing. But when
: 37 tables start becoming really huge it is better to denormalize. When you denormalize
star schema it is nothing but snow flake design. For instance below customeraddress
table is been normalized and is a child table of Customer table. Same holds true for
Salesperson table.

Questions What is ETL process in Data warehousing? What are the different stages in “Data
: 38 warehousing”?

Answers ETL (Extraction, Transformation and Loading) are different stages in Data
: 38 warehousing. Like when we do software development we follow different stages like
requirement gathering, designing, coding and testing. In the similar fashion we have
for data warehousing.
Extraction:-
In this process we extract data from the source. In actual scenarios data source can be
in many forms EXCEL, ACCESS, Delimited text, CSV (Comma Separated Files) etc.
So extraction process handle’s the complexity of understanding the data source and
loading it in a structure of data warehouse.
Transformation:-
This process can also be called as cleaning up process. It’s not necessary that after the
extraction process data is clean and valid. For instance all the financial figures have
NULL values but you want it to be ZERO for better analysis. So you can have some
kind of stored procedure which runs through all extracted records and sets the value
to zero.
Loading:-
After transformation you are ready to load the information in to your final data
warehouse database.

Questions
What is Data mining ?
: 39

Answers Data mining is a concept by which we can analyze the current data from different
: 39 perspectives and summarize the information in more useful manner. It’s mostly used
either to derive some valuable information from the existing data or to predict sales to
increase customer market.
There are two basic aims of Data mining:-

Prediction: -
From the given data we can focus on how the customer or market will perform. For
instance we are having a sale of 40000 $ per month in India, if the same product is to
be sold with a discount how much sales can the company expect.
Summarization: -
To derive important information to analyze the current business scenario. For
example a weekly sales report will give a picture to the top management how we are
performing on a weekly basis?

Questions
Compare Data mining and Data Warehousing ?
: 40

Answers “Data Warehousing” is technical process where we are making our data centralized
: 40 while “Data mining” is more of business activity which will analyze how good your
business is doing or predict how it will do in the future coming times using the
current data. As said before “Data Warehousing” is not a need for “Data mining”. It’s
good if you are doing “Data mining” on a “Data Warehouse” rather than on an actual
production database. “Data Warehousing” is essential when we want to consolidate
data from different sources, so it’s like a cleaner and matured data which sits in
between the various data sources and brings then in to one format. “Data
Warehouses” are normally physical entities which are meant to improve accuracy of
“Data mining” process. For example you have 10 companies sending data in different
format, so you create one physical database for consolidating all the data from
different company sources, while “Data mining” can be a physical model or logical
model. You can create a database in “Data mining” which gives you reports of net
sales for this year for all companies. This need not be a physical database as such but
a simple query.

Questions
What are indexes? What are B-Trees?
: 41

Answers Index makes your search faster. So defining indexes to your database will make your
: 41 search faster.Most of the indexing fundamentals use “B-Tree” or “Balanced-Tree”
principle. It’s not a principle that is something is created by SQL Server or ORACLE
but is a mathematical derived fundamental.In order that “B-tree” fundamental work
properly both of the sides should be balanced.

Questions I have a table which has lot of inserts, is it a good database design to create indexes
: 42 on that table?
Insert’s are slower on tables which have indexes, justify it?or Why do page splitting
happen?

Answers All indexing fundamentals in database use “B-tree” fundamental. Now whenever
: 42 there is new data inserted or deleted the tree tries to become unbalance.
Creates a new page to balance the tree.
Shuffle and move the data to pages.
So if your table is having heavy inserts that means it’s transactional, then you can
visualize the amount of splits it will be doing. This will not only increase insert time
but will also upset the end-user who is sitting on the screen. So when you forecast
that a table has lot of inserts it’s not a good idea to create indexes.

Questions What are the two types of indexes and explain them in detail? or What’s the
: 43 difference between clustered and non-clustered indexes?

Answers There are basically two types of indexes:-


: 43 Clustered Indexes.
Non-Clustered Indexes.
In clustered index the non-leaf level actually points to the actual data.In Non-
Clustered index the leaf nodes point to pointers (they are rowid’s) which then point to
actual data.

Why a database is called as relational database model?

A database model represents the relationship between one or more databases. The relationship is
known as the relational database model. It is an extension of the normal databases without
relations. It provides flexibility and allows one database to be in relation with another database.
It can access the data from many databases at one time over the network.
What are entities and attributes referring to?

- Table consists of some properties that are known as attributes.


- These consist of the representation of entity in the table.
- They are represented by columns in the table.
- Entity is referred to the store data about any particular thing.
- It is the smallest unit inside the table.
What do you understand by relation in relational database model?

Relation in the relational database model is defined as the set of tuples that have the same
attributes. Tuple represents an object and also the information that the object contains. Objects
are basically instances of classes and used to hold the larger picture. Relation is described as a
table and is organized in rows and columns. The data referenced by the relation come in the
same domain and have the same constraints as well. Relations in the relational database model
can be modified using the commands like insert, delete etc.
Why domain is of high importance?

- Domain describes possible values grouped together that can be given for an attribute. It is
considered the same way as a constraint on the value of attribute.
- A domain can be attached to an attribute but only if the attribute is an element of specified set.

For example: XYZ doesn’t fulfill the domain constraint but the integer value as 899 fulfills the
criteria of domain constraint. Hence, domain is of high importance.
What is the difference between base and derived relation?

- Relational database means the relationship between different databases. In relational database
user can store and access all the data through the tables which are related to each other.

- Relationship between the store data is called base relations and implementation of it is called as
tables. Whereas, relations which don’t store the data, but can be found out by applying relational
operations on other relations are called as derived relations. When these are implemented they
are termed as views or queries.

- Derived relations are more useful then base relation, as they can have more information from
many relations, but they act as a single relation.
What are constraints in database?
Constraints are kind of restrictions that are applied to the database or on the domain of an
attribute. For example an integer attribute is restricted from 1-10 and not more than that. They
provide the way to implement the business logic and the rules in database. In database it can be
implemented in the form of check constraints that checks for the rules that haven’t been followed
by the programmer. Constraint also used to restrict the data that can be stored in the relations.
Domain constraint can be applied to check the domain functionality and keep it safe..
8. What are the two principles of relational database model? What is the difference between
them?

The two principal rules for the relational model are as follows:

- Entity integrity: this is used to maintain the integrity at entity level


- Referential integrity: it is used to maintain integrity on all the values which have been
referenced.

The differences between them are as follows:

- Entity integrity tells that in a database every entity should have a unique key; on the other hand
referential integrity tells that in the database every table values for all foreign keys will remain
valid.
- Referential integrity is based on entity integrity but it is not the other way around.
- For example: if a table is present and there is a set of column out of which one column has
parent key set then to ensure that the table doesn’t contain any duplicate values, a unique index is
defined on the column that contains the parent key.
What is the difference between primary and foreign key?

- Primary key uniquely identify a relationship in a database, whereas foreign key is the key that
is in other relation and it has been referenced from the primary key from other table.
- Primary key remains one only for the table, whereas there can be more than one foreign key.
- Primary key is unique and won’t be shared between many tables, but foreign key will be shared
between more than one table and will be used to tell the relationship between them.
Why stored procedures are called as executable code?

Stored procedure stored inside the database. This also includes the executable code that usually
collects and customizes the operations like insert, encapsulation, etc. These stored procedures are
used as APIs for simplicity and security purposes. The implementation of it allows the
developers to have procedural extensions to the standard SQL syntax. Stored procedure doesn’t
come as a part of relational database model, but can be included in many implementations
commercially.
What is an index represent in relational database model?

- Index is a way to provide quick access to the data and structure. It has indexes maintain and can
be created to combine attributes on a relation. Index allows the queries to filter out the searches
faster and matching data can be found earlier with simplicity.

- For example: It is same as the book where by using the index you can directly jump to a
defined section. In relational database there is a provision to give multiple indexing techniques to
optimize the data distribution.
What are the relational operations that can be performed on the database?

There are many relational operators that are used to perform actions on relational database.
These operators are as follows:

1. Union operator that combines the rows of two relations and doesn’t include any duplicate. It
also removes the duplicates from the result.
2. Intersection operator provides a set of rows that two relations have in common.
3. Difference operator provide the output by taking two relations and producing the difference of
rows from first that don’t exist in second.
4. Cartesian product is done on two relations. It acts as a cross join operator.
What do you understand by database Normalization?

- Normalization is very essential part of relational model.


- Normal forms are the common form of normalization.
- It helps in reducing redundancy to increase the information overall.
- It has some disadvantages as it increases complexity and have some overhead of processing.
- It consists of set of procedures that eliminates the domains that are non-atomic and redundancy
of data that prevents data manipulation and loss of data integrity.
What are the different types of normalization that exists in the database?

There are 9 normalizations that are used inside the database. These are as follows:

1. First normal form: in this table represents a relation that has no repeating groups.
2. Second normal form: non- prime attributes are not functional dependent on subset of any
candidate key.
3. Third normal form: in a table every non- prime attribute is non-transitively dependent on
every candidate key
4. Elementary key normal form: superkey dependency or elementary key dependency effects the
functional dependency in a table.
5. Boyce codd normal form: “every non-trivial functional dependency in the table is dependent
on superkey”.
6. Fourth normal form: “Every non-trivial multivalued dependency in the table is a dependent on
a superkey”.
7. Fifth normal form (5NF): “Every non-trivial join dependency in the table is implied by the
superkeys of the table”.
8. Domain/key normal form (DKNF): “Every constraint on the table is a logical consequence of
the table's domain constraints and key constraints”.
9. Sixth normal form (6NF): “Table features no non-trivial join dependencies at all”.
How de-normalization is different from normalization?

- Analytical processing databases are not very normalized. The operations which are used are
read most databases.
- It is used to extract the data that are ancient and accumulated over long period of time. For this
purpose de-normalization occurs that provide smart business applications.
- Dimensional tables in star schema are good example of de-normalized data.
- The de-normalized form must be controlled while extracting, transforming, loading and
processing.
- There should be constraint that user should not be allowed to view the state till it is consistent.
- It is used to increase the performance on many systems without RDBMS platform.
What is the type of de-normalization?

Non-first normal form (NFA)

– It describes the definition of the database design which is different from the first normal form.
- It keeps the values in structured and specialized types with their own domain specific
languages.
- The query language used in this is extended to incorporate more support for relational domain
values by adding more operators.
How many levels of data abstraction are available?

There are three levels of data abstraction available in database model and these are as follows:

1. Physical level: It is the lowest level that describes how data is stored inside the database.
2. Logical level: It is the next higher level in the hierarchy that provides the abstraction. It
describes what data are stored and the relationship between them.
3. View level: It is the highest level in hierarchy that describes part of the entire database. It
allows user to view the database and do the query.
What is the difference between extension and intension?

The major difference between extension and intension is that:

- Extension is time dependent, whereas intension includes a constant value.


- Extension tells about the number of tuples presented in a table at any instance, whereas
intension gives the name, structure and constraint of the table.
What are its two major subsystems of System R?

System R is being developed by IBM. Its purpose is to demonstrate the possible solution to build
a relational database system. The relational database system has to be such that which can
interact with the real life environment to sole real life scenarios.

The two subsystems that are included in it are:

1. Research storage: This includes the research information of the database.


2. System relational system: This includes the relational data that a system has to produce and
keep everything in relation.
What do you understand by Data Independence?

Data independence tells about the independence of the data inside the application. It usually
deals with the storage structure and represents the ability to modify the schema definition. It
doesn’t affect the schema definition which is being written on the higher level.

There are two types of data independence:

1. Physical data independence: It allows the modification to be done in physical level and
doesn’t affect the logical level.
2. Logical data independence: It allow the modification to be done at logical level and affects the
view level.

NOTE: Logical Data Independence is more difficult to achieve.


How view is related to data independence?

- View is a virtual table that doesn’t really exist, but it remains present so that user can view their
data.
- It is derived from the base table. The view is stored in the data dictionary and represents the file
directly.
- The base table updation or reconstruction is not being reflected in views.
- It is related to the logical data independence as it is at the logical level and not at the physical
level.
Why E-R models are used?

E-R model stands for entity-relationship model and it is used to represent a model with their
relationships. This is an object oriented approach and it is based on real world that consists of
objects which are called entities and relationship between them. Entities are further used inside
the database in the form of attributes.
What is the purpose of acid properties?

- ACID stands for Atomicity, Consistency, Isolation and durability and it plays an important role
in the database.
- These properties allow the database to be more convenient to access and use. This allows data
to be shared more safely in between the tables.
- If these properties are not being implemented then the data will become inconsistent and
inaccurate.
- It helps in maintaining the accuracy of the data in the database.
What do you understand by cardinality and why it is used?

- Cardinality is important and used to arrange the data inside the database.
- It is related to the design part and need to be properly used in database.
- It is used in E-R diagrams and used to show the relationship between entities/tables.
- It has many forms like the basic is one to one, which associate one entity with another.
- Second is one to many: which relates one entity with many entities in a table.
- Third is many to many M: N that allows many entities to be related to many more.
- Last is many to one that allows the many entities to be associated with one entity.
What is the difference between DBMS and RDBMS?

- DBMS is persistent and accessible when the data is created or exists, but RDBMS tells about
the relation between the table and other tables.
- RDBS supports a tabular structure for data and relationship between them in the system
whereas DBMS supports only the tabular structure.
- DBMS provide uniform methods for application that has to be independently accessed, but
RDBMS doesn’t provide methods like DBMS but provide relationship which link one entity
with another.
QL stands for

a) Structured Query Language


b) Simple Query Language
c) Standard Query Language
d) Secondary Query Language

ANSWER: a) Structured Query Language

SQL was initially developed by

a) Donald D. Chamberlin and Dr. E.F. Codd


b) Dr. E.F. Codd and Raymond F. Boyce
c) Donald D. Chamberlin and Raymond F. Boyce
d) Michael Widenius

ANSWER: c) Donald D. Chamberlin and Raymond F. Boyce


SQL was designed with the purpose of managing data held in__

a) Relational Database Management System


b) Object Oriented Database Management System
c) Object Relational Database Management System
d) File system

ANSWER: a) Relational Database Management System

Which is the correct syntax to retrieve all rows from the table?

a) select * from table_name;


b) select from table_name;
c) select column_name from table_name;
d) select column_name , from table_name;

ANSWER: a) select * from table_name;


What is the difference between delete and truncate command of SQL?

a) DROP command removes a table from the database & TRUNCATE removes all rows from a
table
b) TRUNCATE TABLE cannot activate a trigger because the operation does not log individual
row deletions.& Delete activates a trigger because the operation are logged individually
c) TRUNCATE TABLE always locks the table and page but not each row & DELETE statement
is executed using a row lock, each row in the table is locked for deletion
d) All of the above

ANSWER: d) All of the above

Restrictions on Dropping Tablespace

a) You cannot drop the SYSTEM tablespace.


b) You cannot drop a tablespace that contains a domain index or any objects created by a domain
index.
c) You cannot drop an undo tablespace if it is being used by any instance or if it contains any
undo data needed to roll back uncommitted transactions.
d) All of the above

ANSWER: d) All of the above


If you want to add new data in a database which command will you use

a) Insert
b) Add
c) Update
d) Select

ANSWER: a) Insert

Suppose your assistant, named Jene has not been previously authorized to add data about new
customers into the database, which of the following statement can be used to give her that
permission

a) Grant Insert
b) Grant Update
c) Revoke Insert
d) Revoke All

ANSWER: a) Grant Insert


SQL select statement is used to

a) Retrieve data from database


b) Update data in database
c) Delete data from database
d) Modify data in database

ANSWER: a) Retrieve data from database

To control access to the database which SQL statement/s used


a) Grant
b) Revoke
c) Both a & b
d) Deny

ANSWER: c) Both a & b


Select the non-aggregate function from the following

a) Avg( )
b) Min( )
c) Max( )
d) Round( )\

ANSWER: d) Round( )

Select the non-scalar function from the following

a) UCASE()
b) LCASE()
c) FORMAT()
d) FIRST()

ANSWER: d) FIRST()
If the primary key is not included in the query result , duplicate rows can occur in result set then
how you can eliminate the duplicate rows of query result.

a) By using Distinct statement


b) By using Unique statement
c) Neither a nor b
d) By using where clause

ANSWER: a) By using Distinct statement

What is true about FLOOR(n) function?

A) Returns smallest integer greater than or equal to n


B) Returns largest integer less than or equal to n
C) It is used with numeric data
D) It operates on character data

a) Only A
b) Only B
c) A , C & D
d) B & C

ANSWER: d) B & C
Pseudo-column ________ returns a level of row in a tree-structured query.

a) ROWID
b) LEVEL
c) ROWNUM
d) ROWSCN

ANSWER: b) LEVEL

Pseudo-column LEVEL can be used in ____statement where ______ is used.

a) Select, group by
b) Select , connect by
c) Update, order by
d) Select , group by

ANSWER: b) Select , connect by


____ column displays the location of row in a database.

a) ROWID
b) ROWNUM
c) ROWSCN
d) UID

ANSWER: a) ROWID

To use the result of certain query repeatedly which clause will you use?

a) Where
b) With
c) Having
d) None of the above

ANSWER: b) With
Which command will you use to delete entire table from database?

a) Delete
b) Drop
c) Truncate
d) None of the above

ANSWER: b) Drop

SQL ______performs a JOIN against equality or matching column(s) values of the associated
tables.
a) Equi join(answer)
b) Inner Join
c) Self-Join
d) Cross Join
Exists clause is used for

a) Testing whether a given set is empty or not


b) Testing whether given set is valid
c) Testing whether a given set is invalid
d) Testing whether a given set is exists

ANSWER: a) Testing whether a given set is empty or not.

Which of the following queries will correctly show the tables owned by the user?

a) SELECT table_name from system_user_tables;


b) SELECT table_name from user_objects;
c) SELECT table_name from user_catalog;
d) SELECT table_name from user_tables;

ANSWER: d) SELECT table_name from user_tables;


Data files are logically grouped together into an oracle logical structure called a

a) Tablespace
b) Table
c) Database
d) Indexes

ANSWER: a) Tablespace

To create a table name Customer having fields Cust-name, Cust_address from the table
Employee and Customer table should not be populated with any record from Employee table
which of the following query will be correct?

a) Create table Customer (Cust-name, Cust_address) As Select emp_name, emp_address from


Employee;
b) Create table Customer (Cust-name, Cust_address) As Select emp_name, emp_address from
Employee 1=1;
c) Create table Customer (Cust-name, Cust_address) As Select emp_name, emp_address from
Employee where 1=2;
d) Create table Customer (Cust-name, Cust_address) As Select emp_name, emp_address from
Employee where a=b;

ANSWER: c) Create table Customer (Cust-name, Cust_address) As Select emp_name,


emp_address from Employee where 1=2;
Which of the following tasks cannot be performed when using Alter Table clause?

A) Change the name of the table


B) Change the name of the column
C) Decrease the size of a column if table data exists

a) A & B
b) A,B, & C
c) Only C
d) B & C

ANSWER: b) A,B, & C

The _______ command is used to change or modify data values in a table

a) Update
b) Modify
c) Rename
d) Describe

ANSWER: a) Update
Up to how many columns can be combined to form a composite primary key for a table?

a) 16
b) 8
c) 18
d) 14

ANSWER: a) 16

Select from the following option which not true about primary key

a) Primary key can be Long & long Raw data type


b) Unique index is created automatically if there is a Primary Key
c) Primary key will not allow Null values
d) Primary key will not allow duplicate values

ANSWER: a) Primary key can be Long & long Raw data type
To compare one value with more than one or list of values then which of the following operator
will fulfil the need?

a) Like
b) IN
c) AND
d) Between
ANSWER: b) IN

Which of the following query is correctly give the user name of the currently logged in user?

a) SELECT USERENV FROM DUAL;


b) SELECT COALESCE FROM DUAL;
c) SELECT USER FROM DUAL;
d) SELECT USERENV FROM TABLE_NAME;

ANSWER: c) SELECT USER FROM DUAL;


The ___ operator is used to calculate aggregates and super aggregates for expressions within a
________.

a) ROLLUP, GROUP BY
b) ROLLUP, ORDER BY
c) CUBE , GROUP BY
d) ROLLUP,CUBE

ANSWER: a) ROLLUP, GROUP BY

________ allows grantee to in turn grant object privileges to other users.

a) With grant option


b) Grant
c) Revoke
d) Grant All

ANSWER: a) With grant option


Grant all on Customer to Reeta with grant option, what is the significance of ‘with grant option’
in this query?

a) Give the user “Reeta” privileges to view only data on table Customer along with an option to
further grant permissions on the Customer table to other users.
b) Give the user “Reeta” all data manipulation privileges on table Customer.
c) Give the user “Reeta” all data manipulation privileges on table Customer along with an option
to further grant permissions on the Customer table to other users.
d) Give the user “Reeta” all data manipulation privileges on table Customer along with an option
to not further grant permissions on the Customer table to other users.

ANSWER: c) Give the user “Reeta” all data manipulation privileges on table Customer along
with an option to further grant permissions on the Customer table to other users.

A View is mapped to __________ statement.

a) Update
b) Alter
c) Create
d) Select

ANSWER: d) Select
What are the prerequisite for a View to be updateable?

a) Views defined from a single table. If user wants to Insert records with the help of a view, then
the primary key column and all the Not Null columns must be included in the view
b) The user can Update, Delete records with the help of a view even if the primary key column
and Not Null column(s) are executed from the view definition
c) Both a & b
d) None of the above

ANSWER: c) Both a & b

Which of the following query will correctly create the view of Employee table having fields
fname,lname,dept?

a) Create View emp_v In select fname,lname,dept from Employee;


b) Create View emp_v As select fname,lname,dept from Employee;
c) Create View emp_v like select fname,lname,dept from Employee;
d) Create View emp_v As select , , fname,lname,dept , ,from Employee;

ANSWER: b) Create View emp_v As select fname,lname,dept from Employee;


Which of the following column is not a part of USER_CONSTRAINTS?

a) OWNER
b) TABLE_NAME
c) SEARCH_CONDITION\
d) DB_DOMAIN

ANSWER: d) DB_DOMAIN

_______ used to sort the data in the table

a) Order by clause
b) Group by clause
c) Aggregate functions
d) Sequence

ANSWER: a) Order by clause


______ clause can be used to find unique values in situations to which ____ apply.

a) HAVING, DISTINCT does not


b) HAVING, DISTINCT
c) GROUP BY, DISTINCT
d) HAVING, GROUP BY

ANSWER: a) HAVING, DISTINCT does not.

Which of the following is not a valid SQL data type?

a) NUMBER
b) DATE
c) LONG
d) FRACTION

ANSWER: d) FRACTION
_____ condition can’t contain sub queries or sequence.

a) Check
b) Unique
c) References
d) Index

ANSWER: a) Check

What is true about join?

a) You can join a maximum of two tables


b) You can join a maximum of two columns through
C) You can join two or more tables
d) None of the above

ANSWER: You can join two or more tables.


Joining a table to itself is referred to as __________.

a) Self-join
b) Cross-join
c) Outer Join
d) Full Outer Join

ANSWER: a) Self-join

A sub query is a form of an SQL statement that appears ______ another SQL statement.

a) At the start of
b) Inside
c) Outside
d) After

ANSWER: b) Inside
The____ data types are used to store binary data.

a) Raw
b) LONG
c) bfile
d) rowid

ANSWER: a) Raw

A____ level constraint must be applied if data constraint spans across multiple columns in a
table.

a) Table
b) Row
c) Column
d) Database

ANSWER: a) Table
______ constraint can only applied at column level.

a) NOT NULL
b) CHECK
c) UNIQUE
d) PRIAMRY KEY

ANSWER: a) NOT NULL

EXTRACT() function returns ___________.

a) a value extracted from a date or an interval value


b) number of columns in a table
c) number of tables in a database
d) number of rows in a table

ANSWER: a) a value extracted from a date or an interval value


Which of the following is a string function?

a) UPPER( )
b) FLOOR( )
c) LEAST( )
d) ABS( )

ANSWER: a) UPPER( )

VSIZE( ) function returns ___________.


a) number of bytes in the internal representation of an expression
b) number of rows where expr is not null
c) largest integer value
d) returns a Unicode string

ANSWER: a) number of bytes in the internal representation of an expression.

CHECK OUT THESE QUESTIONS: 1. What is a Database?


2. What is DBMS?
3 What is a Catalog?
4. What is data ware housing & OLAP?
5. What is real time database technology?
6. What is program-data independence?
7. What is ORDBMS?
8. What is program-operation independence?
9. What is a view?
10. What is OLTP?
11. What is the job of DBA?
12. Who are db designer?
13. What are different types of end users?
14. What are the advantages of using a dbms?
15. What are the disadvantages of using a dbms?
16. What is a data model?
17. What are different categories of data models?
18. What is schema?
19. What are types of schema?
20. What is Data independency?
21. What are different DBMS languages?
22. What are different types of DBMS?
23. What is an entity?
24. What are attributes?
25. What are diff. types of attributes?
26. What is difference between entity set and entity type?
27. What is domain value or value set of an attribute?
28. What is degree of a relationship?
29. What is recursive relationship?
30. What are relationship constraints?
31. What is Cardinality ratio?
32. What is a Participation constraint?
33. What is a weak entity types?
34. What is an ER Diagram?
35. What is an EER?
36. What is specialization?
38. What is generalization?
38. What are constraints on generalization and specialization?
39. What is a ternary relationship?
40. What is aggregation and association?
41. What is RAID Technology?
42. What is Hashing technique?
43. What are different types of relational constraints?
44. What is difference between a super key, a key, a candidate key and a primary key?
45. What is a foreign key?
46. What is a transaction?
47. What are the properties of transaction?
48. What are the basic data base operations?
49. What are the disadvantages of not controlling concurrency?
50. What are serial, non serial?
51. What are conflict serializable schedules?
52. What is result equivalent?
53. What are conflict equivalent schedules?
54. What is a conflict serializable schedule?
55. What is view equivalence?
56. What is view serializable?
57. What are the various methods of controlling concurrency?
58. What is a lock?
59. What are various types of locking techniques?
60. What is a binary lock?
61. What is shared or exclusive lock?
62. What are different types of two phase lockings(2pl)?
63. What is a deadlock?
64. What are triggers?

Refer: http://www.freejobalert.com/dbms-interview-questions-and-answers-part6/6424/

Das könnte Ihnen auch gefallen