Monday 9 January 2017

DBMS Interview Questions

DBMS Interview Questions

image
dbms interview questions



What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model.
RDBMS: Array
Network Model: Graph
Hierarchical Model: Tree/Linked List
If you are using C language to implement the heterogeneous linked list, what pointer type will you use?
Void pointer
What is database?
ANSWER:
A database is a logically coherent collection of data with some inherent meaning, representing some aspect of real world and which is designed, built and populated with data for a specific purpose.
What is DBMS? State its advantages/features
ANSWER: Database management system
? Redundancy is controlled.
? Unauthorised access is restricted.
? Providing multiple user interfaces.
? Enforcing integrity constraints.
? Providing backup and recovery.
What is a Database system?
ANSWER:
The database and DBMS software together is called as Database system.
Disadvantage in File Processing System?
ANSWER:
? Data redundancy & inconsistency.
? Difficult in accessing data.
? Data isolation.
? Data integrity.
? Concurrent access is not possible.
? Security Problems. .
Describe the three levels of data abstraction?
ANSWER:
The are three levels of 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.
Define the "integrity rules"
ANSWER:
There are two Integrity rules.
? Entity Integrity: States that ?Primary key cannot have NULL value?
? Referential Integrity: States that ?Foreign Key can be either a NULL value or should be Primary Key value of other relation.
What is System R? What are its two major subsystems?
ANSWER:
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
? Research Storage
? System Relational Data System.
What is Data Independence?
ANSWER:
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:
? Physical Data Independence : Modification in physical level should not affect the logical level.
? Logical Data Independence : Modification in logical level should affect the view level.
NOTE: Logical Data Independence is more difficult to achieve
What is a view? How it is related to data independence?
ANSWER:
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. .
What is Data Model?
ANSWER:
A collection of conceptual tools for describing data, data relationships data semantics and constraints.
What is Object Oriented model?
ANSWER:
This model is based on collection of objects. An object contains values stored in instance variables with in the object. An object also contains bodies of code that operate on the object. These bodies of code are called methods. Objects that contain same types of values and the same methods are grouped together into classes.
What is an Entity type?
ANSWER:
It is a collection (set) of entities that have same attributes.
What is an Entity set?
ANSWER:
It is a collection of all entities of particular entity type in the database.
What is degree of a Relation?
ANSWER:
It is the number of attribute of its relation schema.
What is DML (Data Manipulation Language)? What are its types?
ANSWER:
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.
What is DML Compiler?
ANSWER:
It translates DML statements in a query language into low-level instruction that the query evaluation engine can understand.
What is Query evaluation engine?
ANSWER:
It executes low-level instruction generated by compiler.
What is Relational Algebra?
ANSWER:
It is procedural query language. It consists of a set of operations that take one or two relations as input and produce a new relation.
What is normalization?
ANSWER:
It is a process of analysing the given relation schemas based on their Functional Dependencies (FDs) and primary key to achieve the properties
? Minimizing redundancy
? Minimizing insertion, deletion and update anomalies.
What is Functional Dependency? Give example
ANSWER:
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.
What is Multivalued dependency?
ANSWER:
Multivalued dependency denoted by X Y specified on relation schema R, where X and Y are both subsets of R, specifies the following constraint on any relation r of R: if two tuples t1 and t2 exist in r such that t1[X] = t2[X] then t3 and t4 should also exist in r with the following properties
? t3[x] = t4[X] = t1[X] = t2[X]
? t3[Y] = t1[Y] and t4[Y] = t2[Y]
? t3[Z] = t2[Z] and t4[Z] = t1[Z]
where [Z = (R-(X U Y)) ]
What is 3NF?
ANSWER:
A relation schema R is in 3NF if it is in 2NF and for every FD X A either of the following is true
? X is a Super-key of R.
? A is a prime attribute of R.
In other words, if every non prime attribute is non-transitively dependent on primary key.
What is BCNF (Boyce-Codd Normal Form)?
ANSWER:
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.
What is "transparent DBMS"?
It is one, which keeps its Physical Structure hidden from user.
Brief theory of Network, Hierarchical schemas and their properties
Network schema uses a graph data structure to organize records example for such a database management system is CTCG while a hierarchical schema uses a tree data structure example for such a system is IMS.
What do you mean by Correlated subquery? Give example
 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.
 E.g. Select * From CUST Where '10/03/1990' IN (Select ODATE From ORDER Where CUST.CNUM = ORDER.CNUM)
What are the primitive operations common to all record management systems?
Addition, deletion and modification.
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.
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
What is the purpose 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.
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.
What is an Oracle Instance?
The Oracle system processes, also known as Oracle background processes, provide functions for the user processes—functions that would otherwise be done by the user processes themselves
Oracle database-wide system memory is known as the SGA, the system global area or shared global area. The data and control structures in the SGA are shareable, and all the Oracle background processes and user processes can use them.
The combination of the SGA and the Oracle background processes is known as an Oracle instance
What are database files, control files and log files. How many of these files should a database have at least? Why?
Database Files
The database files hold the actual data and are typically the largest in size. Depending on their sizes, the tables (and other objects) for all the user accounts can go in one database file—but that's not an ideal situation because it does not make the database structure very flexible for controlling access to storage for different users, putting the database on different disk drives, or backing up and restoring just part of the database.
You must have at least one database file but usually, more than one files are used. In terms of accessing and using the data in the tables and other objects, the number (or location) of the files is immaterial.
The database files are fixed in size and never grow bigger than the size at which they were created
Control Files
The control files and redo logs support the rest of the architecture. Any database must have at least one control file, although you typically have more than one to guard against loss. The control file records the name of the database, the date and time it was created, the location of the database and redo logs, and the synchronization information to ensure that all three sets of files are always in step. Every time you add a new database or redo log file to the database, the information is recorded in the control files.
Redo Logs
Any database must have at least two redo logs. These are the journals for the database; the redo logs record all changes to the user objects or system objects. If any type of failure occurs, the changes recorded in the redo logs can be used to bring the database to a consistent state without losing any committed transactions. In the case of non-data loss failure, Oracle can apply the information in the redo logs automatically without intervention from the DBA.
The redo log files are fixed in size and never grow dynamically from the size at which they were created.
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.
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.
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
Ø Implicit
Ø Explicit
What operator performs pattern matching?
LIKE operator
Which command executes the contents of a specified file?
  START <filename> or @<filename>
State true or false. EXISTS, SOME, ANY are operators in SQL.
  True
Which system table contains information on constraints on all the tables created?
  USER_CONSTRAINTS
What is the difference between TRUNCATE and DELETE commands?
  TRUNCATE is a DDL command whereas DELETE is a DML command. Hence DELETE operation can be rolled back, but TRUNCATE operation cannot be rolled back. WHERE clause can be used with DELETE and not with TRUNCATE.
What will be the output of the following query?
SELECT REPLACE(TRANSLATE(LTRIM(RTRIM('!! ATHEN !!','!'), '!'), 'AN', '**'),'*','TROUBLE') FROM DUAL;
  TROUBLETHETROUBLE
What does the following query do?
SELECT SAL + NVL(COMM,0) FROM EMP;
  This displays the total salary of all employees. The null values in the commission column will be replaced by 0 and added to salary.
What is the advantage of specifying WITH GRANT OPTION in the GRANT command?
  The privilege receiver can further grant the privileges he/she has obtained from the owner to any other user.
What is the use of the DROP option in the ALTER TABLE command?
  It is used to drop constraints specified on the table.
What is the use of DESC and CASCADE in SQL commands?
Answer :
  DESC has two purposes. It is used to describe a schema as well as to retrieve rows from table in descending order.
Explanation :
The query SELECT * FROM EMP ORDER BY ENAME DESC will display the output sorted on ENAME in descending order.

CASCADE
  When this clause is used with the DROP command, a parent table can be dropped even when a child table exists.
e.g. ON DELETE CASCADE




EmoticonEmoticon