Beruflich Dokumente
Kultur Dokumente
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 ?
3. What is SQL ?
A record is the collection of values / fields of a specific entity: i.e. an Employee, Salary etc.
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.
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.
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
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.
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 :
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 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
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:
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.
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.
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.
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
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.
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.
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.
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?
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.
I. Redundancy is controlled.
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.
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.
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.
A data base schema is specifies by a set of definitions expressed by a special language called
DDL.
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
It translates DML statements in a query language into low-level instruction that the query
evaluation engine can understand.
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:
2. Create separate tables for each group of related data and identify each row with a unique
column (the primary key).
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.
A table is in Boyce-Codd normal form (BCNF) if and only if it is in 3NF and every determinant
is a candidate key.
Fourth normal form requires that a table be BCNF and contain no multi-valued dependencies.
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.
A query with respect to DBMS relates to user commands that are used to interact with a data
base.
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.
Relational Data Base Management Systems (RDBMS) are database management systems that
maintain data records and indices in tables.
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.
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.
A stored procedure is a named group of SQL statements that have been previously created and
stored in the server database.
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.
A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or
UPDATE) occurs.
31. What is Index?
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.
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.
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.
I/O, Security, Language Processing, Process Control, Storage Management, Logging and
Recovery, Distribution Control, Transaction Control, Memory Management, Lock Management.
· Data isolation.
· Data integrity.
· Security Problems.
This language is to specify the internal schema. This language may Specify the mapping between
two schemas.
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.
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.
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.
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.
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.
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.
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 .
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.
Data independence means that the application is independent of the storage structure and access
strategy of data.
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
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.
Collation refers to a set of rules that determine how data is sorted and compared.
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.
This is a primary file organization technique that provides very fast access to records on certain
search conditions.
A transaction is a logical unit of database processing that includes one or more database access
operations.
Analysis phase
Redo phase
Undo phase
61. What are the primitive operations common to all record management System?
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.
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.
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.
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.
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?
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.
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).
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.
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.
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.
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.
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.
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.
It is the process of finding common attributes and relations of a number of entities and defining a
common super class for them.
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.
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.
A schedule is said to be view serializable if it is view equivalent with some serial schedule.
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.
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. 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.
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.
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
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.
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 :-
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
Questions
What are different types of joins in SQL?
: 19
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
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
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.
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
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?
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?
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 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?
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?
– 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?
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.
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.
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.
- 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
Which is the correct syntax to retrieve all rows from the table?
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
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
a) Avg( )
b) Min( )
c) Max( )
d) Round( )\
ANSWER: d) Round( )
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) 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
a) Select, group by
b) Select , connect by
c) Update, order by
d) Select , group by
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
Which of the following queries will correctly show the tables owned by the user?
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) A & B
b) A,B, & C
c) Only C
d) B & C
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
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) ROLLUP, GROUP BY
b) ROLLUP, ORDER BY
c) CUBE , GROUP BY
d) ROLLUP,CUBE
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) 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
Which of the following query will correctly create the view of Employee table having fields
fname,lname,dept?
a) OWNER
b) TABLE_NAME
c) SEARCH_CONDITION\
d) DB_DOMAIN
ANSWER: d) DB_DOMAIN
a) Order by clause
b) Group by clause
c) Aggregate functions
d) Sequence
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
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
a) UPPER( )
b) FLOOR( )
c) LEAST( )
d) ABS( )
ANSWER: a) UPPER( )
Refer: http://www.freejobalert.com/dbms-interview-questions-and-answers-part6/6424/