DBMS Imp Questions Answers
DBMS Imp Questions Answers
1. 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.
2. 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.
4. Advantages of DBMS?
? Redundancy is controlled.
? Unauthorized access is restricted.
? Providing multiple user interfaces.
? Enforcing integrity constraints.
? Providing backup and recovery.
38. How does Tuple-oriented relational calculus differ from domain-oriented relational calculus
The tuple-oriented calculus uses a tuple variables i.e., variable whose only permitted values are tuples of
that relation. E.g. QUEL
The domain-oriented calculus has domain variables i.e., variables that range over the underlying
domains instead of over relation. E.g. ILL, DEDUCE.
52. What are partial, alternate,, artificial, compound and natural key?
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.
Alternate Key:
All Candidate Keys excluding the Primary Key are known as Alternate Keys.
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.
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.
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:
? Binary search style indexing
? B-Tree indexing
? Inverted list indexing
? Memory resident table
? 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.
67. What are the primitive operations common to all record management systems?
Addition, deletion and modification.
68. Name the buffer in which all the commands that are typed in are stored
? Edit? Buffer
70. 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.
73. 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.
77. 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.
78. 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
? Database files
? Control files
? 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 the entire database using a backup, if there is one.
80. What are the four Oracle system processes that must always be up and running for the database to be
useable
The four Oracle system processes that must always be up and running for the database to be useable
include DBWR (Database Writer), LGWR (Log Writer), SMON (System Monitor), and PMON (Process
Monitor).
81. 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 file 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 redoes 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.
83. What is Oracle Block? Can two Oracle Blocks have the same address?
Oracle "formats" the database files into a number of Oracle blocks when they are first created? Making
it easier for the RDBMS software to manage the files and easier to read data into the memory areas.
The block size should be a multiple of the operating system block size. Regardless of the block size, the
entire block is not available for holding data; Oracle takes up some space to manage the contents of the
block. This block header has a minimum size, but it can grow.
These Oracle blocks are the smallest unit of storage. Increasing the Oracle block size can improve
performance, but it should be done only when the database is first created.
Each Oracle block is numbered sequentially for each database file starting at 1. Two blocks can have the
same block address if they are in different database files.
85. Name two utilities that Oracle provides, which are use for backup and recovery.
Along with the RDBMS software, Oracle provides two utilities that you can use to back up and restore
the database. These utilities are Export and Import.
The Export utility dumps the definitions and data for the specified part of the database to an operating
system binary file. The Import utility reads the file produced by an export, recreates the definitions of
objects, and inserts the data
If Export and Import are used as a means of backing up and recovering the database, all the changes
made to the database cannot be recovered since the export was performed. The best you can do is
recover the database to the time when the export was last performed.
86. 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.
87. How are exceptions handled in PL/SQL? Give some of the internal exceptions' name
PL/SQL exception handling is a mechanism for dealing with run-time errors encountered during
procedure execution. Use of this mechanism enables execution to continue if the error is not severe
enough to cause procedure termination.
The exception handler must be defined within a subprogram specification. Errors cause the program to
raise an exception with a transfer of control to the exception-handler block. After the exception handler
executes, control returns to the block in which the handler was defined. If there are no more executable
statements in the block, control returns to the caller.
User-Defined Exceptions
PL/SQL enables the user to define exception handlers in the declarations area of subprogram
specifications. User accomplishes this by naming an exception as in the following example:
Ot_failure EXCEPTION;
In this case, the exception name is ot_failure. Code associated with this handler is written in the
EXCEPTION specification area as follows:
EXCEPTION
When OT_FAILURE then
out_status_code:= g_out_status_code;
out_most:= g_out_msg;
The following is an example of a subprogram exception:
EXCEPTION
When NO_DATA_FOUND then
g_out_status_code:= 'FAIL';
RAISE ot_failure;
Within this exception is the RAISE statement that transfers control back to the ot_failure exception
handler. This technique of raising the exception is used to invoke all user-defined exceptions.
System-Defined Exceptions
Exceptions internal to PL/SQL are raised automatically upon error. NO_DATA_FOUND is a system-
defined exception. Table below gives a complete list of internal exceptions.
In addition to this list of exceptions, there is a catch-all exception named OTHERS that traps all errors
for which specific error handling has not been established.
Full recordings of two tables is Union All operator.A distinct recording of two tables is Union.
A database object which helps in manipulating data row by row representing a result set is called cursor.
92) Enlist the cursor types.
They are:
• Implicit cursor: Declared automatically as soon as the execution of SQL takes place without the
awareness of the user.
• Explicit cursor: Defined by PL/ SQL which handles query in more than one row.
Both having B-tree structure, non-clustered index has data pointers enabling one table many non-
clustered indexes while clustered index is distinct for every table.
Functions which operate against a collection of values and returning single value is called aggregate
functions
Scalar function is depended on the argument given and returns sole value.
102) What restrictions can you apply when you are creating views?
Storage and access of data from the central location in order to take some strategic decision is called
Data Warehousing. Enterprise management is used for managing the information whose framework is
known as Data Warehousing.
Joins help in explaining the relation between different tables. They also enable you to select data with
relation to data in another table.
• INNER JOINs: Blank rows are left in the middle while more than equal to two tables are joined.
• OUTER JOINs: Divided into Left Outer Join and Right Outer Join. Blank rows are left at the
specified side by joining tables in other side.
Other joins are CROSS JOINs, NATURAL JOINs, EQUI JOIN and NON-EQUI JOIN.
Indexes help in improving the speed as well as the query performance of database. The procedure of
boosting the collection of indexes is named as Index hunting.
Index hunting helps in improving the speed as well as the query performance of database. The followed
measures are achieved to do that:
• The query optimizer is used to coordinate the study of queries with the workload and the best use
of queries suggested based on this.
• Index, query distribution along with their performance is observed to check the effect.
• Tuning databases to a small collection of problem queries is also recommended.
• No indexes
• Stored procedures are excessively compiled.
• Triggers and procedures are without SET NOCOUNT ON.
• Complicated joins making up inadequately written query.
• Cursors and temporary tables showcase a bad presentation.
• SQL Server caches collected procedure or the plan of query execution and used thereafter by
subsequent calls.
• An important feature in relation to performance enhancement.
• Data execution plan can be viewed textually or graphically.
A data structure in the form of tree which stores sorted data and searches, insertions, sequential access
and deletions are allowed in logarithmic time.
Iterating over all the table rows is called Table Scan while iterating over all the index items is defined as
Index Scan.
113) What do you mean by Fill Factor concept with respect to indexes?
Fill Factor can be defined as being that value which defines the percentage of left space on every leaf-
level page that is to be packed with data. 100 is the default value of Fill Factor.
Fragmentation can be defined as a database feature of server that promotes control on data which is
stored at table level by the user.
An outer loop within an inner loop is formed consisting of fewer entries and then for individual entry,
inner loop is individually processed.
E.g.
• outer_loop
• inner_loop
• Hash join
• Build: It is a hash table having in-memory which is present on the smaller table.
• Probe: this hash value of the hash table is applicable for each second row element.
• Sort merge join
Two independent sources of data are joined in sort merge join. They performance is better as compared
to nested loop when the data volume is big enough but it is not good as hash joins generally.The full
operation can be divided into parts of two:
Division of logical database into independent complete units for improving its management, availability
and performance is called Database partitioning.
Splitting of one table which is large into smaller database entities logically is called database
partitioning. Its benefits are:
• To improve query performance in situations dramatically when mostly rows which are heavily
accessed are in one partition.
• Accessing large parts of a single partition
• Slower and cheaper storage media can be used for data which is seldom used.
118) Define Database system.
Query Evaluation Engine executes the low-level instructions that are generated by the compiler.
Atomicity: It’s an all or none concept which enables the user to be assured of incomplete transactions to
be taken care of. The actions involving incomplete transactions are left undone in DBMS.
Aggregation: The collected entities and their relationship are aggregated in this model. It is mainly used
in expressing relationships within relationships.
• Analysis Phase.
• Redo Phase
• Undo Phase
Compilations of objects make up this model in which values are stored within instance variables which
is inside the object. The object itself comprises bodies of object for its operation which are called
methods. Objects containing same kind of variables and methods are called classes.
It can be defined as being a ‘thing’ with an independent existence in the real world.
Compilation of all entries of any particular type of entry in the database is called Entity Set.
Compilation of similar entity types into one particular type which is grouped together as an entity set.
128)Define Denormalization.
Boosting up database performance, adding of redundant data which in turn helps rid of complex
data is called denormalization.
They are:
CREATE:
ALTER:
DROP:
132)Define cursor.
A database object which helps in manipulating data row by row representing a result set is called
cursor.
They are:
• Implicit cursor: Declared automatically as soon as the execution of SQL takes place without
the awareness of the user.
• Explicit cursor: Defined by PL/ SQL which handles query in more than one row.
135)Define sub-query.
Both having B-tree structure, non-clustered index has data pointers enabling one table many non-
clustered indexes while clustered index is distinct for every table.
Functions which operate against a collection of values and returning single value is called aggregate
functions
139)Define Scalar functions.
Scalar function is depended on the argument given and returns sole value.
140)What restrictions can you apply when you are creating views?
A ‘correlated subquery’ is a sort of sub query but correlated subquery is reliant on another query
for a value that is returned. In case of execution, the sub query is executed first and then the
correlated query.
Storage and access of data from the central location in order to take some strategic decision is
called Data Warehousing. Enterprise management is used for managing the information whose
framework is known as Data Warehousing.
Joins help in explaining the relation between different tables. They also enable you to select data
with relation to data in another table.
• INNER JOINs: Blank rows are left in the middle while more than equal to two tables
are joined.
• OUTER JOINs: Divided into Left Outer Join and Right Outer Join. Blank rows are left at
the specified side by joining tables in other side.
Other joins are CROSS JOINs, NATURAL JOINs, EQUI JOIN and NON-EQUI JOIN.
Indexes help in improving the speed as well as the query performance of database. The procedure of
boosting the collection of indexes is named as Index hunting.
Questions & Answers- MySQL
145)What is MySQL?
MySQL is an open source DBMS which is built, supported and distributed by MySQL AB
(now acquired by Oracle)
MySQL database server is reliable, fast and very easy to use. This software can be downloaded as
freeware and can be downloaded from the internet.
HEAP tables are present in memory and they are used for high speed storage on temporary
basis.
• MySQL is open source software which is available at any time and has no cost involved.
• MySQL is portable
• GUI with command prompt.
• Administration is supported using MySQL Query Browser
151)Difference between CHAR and VARCHAR?
• SET
• BLOB
• ENUM
• CHAR
• TEXT
• VARCHAR
• PHP Driver
• JDBC Driver
• ODBC Driver
• C WRAPPER
• PYTHON Driver
• PERL Driver
• RUBY Driver
• CAP11PHP Driver
• Ado.net5.mxj
TIMESTAMP column is updated with Zero when the table is created. UPDATE
CURRENT_TIMESTAMP modifier updates the timestamp field to current time whenever there is
a change in other fields of the table.
Primary Key is also a candidate key. By common convention, candidate key can be designated as
primary and which can be used for any foreign key references.
Timestamp field gets the current timestamp whenever the row gets altered.
158)What happens when the column is set to AUTO INCREMENT and if you reach
maximum value in the table?
It stops incrementing. Any further inserts are going to produce an error, since the key has been used
already.
159)How can we find out which auto increment was assigned on Last insert?
LAST_INSERT_ID will return the last value assigned by Auto_increment and it is not required
to specify the table name.
NOW() command is used to show current year, month, date with hours, minutes and seconds
while CURRENT_DATE() shows the current year with month and date only.
The DELETE command is used to delete data from a table. It only deletes the rows of data from
the table while, truncate is very dangerous command and should be used carefully because it
deletes every row permanently from a table.
Questions & Answers- NoSQL
167)What is NoSQL?
NoSQL encompasses a wide variety of different database technologies that were developed in
response to a rise in the volume of data stored about users, objects and products. The frequency in
which this data is accessed, and performance and processing needs. Relational databases, on the
other hand, were not designed to cope with the scale and agility challenges that face modern
applications, nor were they built to take advantage of the cheap storage and processing power
available today.
When compared to relational databases, NoSQL databases are more scalable and provide superior
performance, and their data model addresses several issues that the relational model is not designed
to address:
Mongo-DB is a document database which provides high performance, high availability and easy
scalability.
MongoDB stores BSON (Binary Interchange and Structure Object Notation) objects in the
collection. The concatenation of the collection name and database name is called a namespace.
172) What is sharding in MongoDB?
The procedure of storing data records across multiple machines is referred as Sharding. It is a
MongoDB approach to meet the demands of data growth. It is the horizontal partition of data in a
database or search engine. Each partition is referred as shard or database shard.
A replica set is a group of mongo instances that host the same data set. In replica set, one node is
primary, and another is secondary. From primary to the secondary node all data replicates.
Across multiple servers, the process of synchronizing data is known as replication. It provides
redundancy and increase data availability with multiple copies of data on different database
server. Replication helps in protecting the database from the loss of a single server.
176)While creating Schema in MongoDB what are the points need to be taken
in consideration?
177) What is the syntax to create a collection and to drop a collection in MongoDB?
MongoDB database profiler shows performance characteristics of each operation against the
database. You can find queries using the profiler that are slower than they should be.
Yes, it is possible to move old files in the moveChunk directory, during normal shard balancing
operations these files are made as backups and can be deleted once the operations are done.
180)To do safe backups what is the feature in MongoDB that you can use?
Journaling is the feature in MongoDB that you can use to do safe backups.
181)Mention what is Objecld composed of?
Objectld is composed of
a. Timestamp
b. Client machine ID
c. Client process ID
d. 3 byte incremented counter
To inspect a source code of a function, without any parentheses, the function must be invoked.
184)What is the command syntax that tells you whether you are on the master server or not? And
how many master does MongoDB allow?
Command syntax Db.isMaster() will tell you whether you are on the master server or not. MongoDB
allows only one master server, while couchDB allows multiple masters.
185)Mention the command syntax that is used to view Mongo is using the link?
The command syntax that is used to view mongo is using the link is
db._adminCommand(“connPoolStats.”)
Indexes are special structures in MongoDB, which stores a small portion of the data set in an easy to traverse
form. Ordered by the value of the field specified in the index, the index stores the value of a specific field or set
of fields.
The basic syntax to use in MongoDB is >db.COLLECTION_NAME.ensureIndex ( {KEY:1} ). In here the key
is the the name of the COLUMN (or KEY:VALUE pair) which is present in the documents.
For storing and retrieving large files such as images, video files and audio files GridFS is used. By default, it uses
two files fs.files and fs.chunks to store the file’s metadata and the chunks.
A transaction is a logical unit of database processing that includes one or moredatabase access
operations.
191)What are the different phases of Transaction?
Analysis phase
phase
Structured data are facts concerning objects and events. The most importantstructured 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. Unstructureddata are most commonly found on Web servers
and Web-enabled databases.
A dependency graph is a diagram that is used to portray the connections betweendatabase elements.
An exclusive lock prohibits other users from reading the locked resource; a sharedlock allows other users to
read the locked resource, but they cannot update it.
SQL statements return a set of rows, while an application program works on one rowat 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.
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.
202)What is Enterprise Resource Planning (ERP), and what kind of adatabase is used in an ERP
application?
Enterprise Resource Planning (ERP) is an information system used in manufacturingcompanies and includes
sales, inventory, production planning, purchasing and otherbusiness functions. An ERP system typically uses a
multiuser database.
Embedded SQL is the process of including hard coded SQL statements. These statements do not change unless
the source code is modified. Dynamic SQL is the process of generating SQL on the fly.The statements
generated do not have to be thesame each time.
A join allows tables to be linked to other tables when a relationship between the tablesexists. The relationships are
established by using a common column in the tables andoften uses the primary/foreign key relationship.
205)Describe a subquery.
A subquery is a query that is composed of two queries. The first query (inner query) iswithin 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 andone-to-many relationships.
The network model can be much more flexible than the hierarchical model since eachparent 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).
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 relationis in second normal form, you must remove all transitive
dependencies.
209)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 rowand 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 instanceof another entity.
211)What is deadlock? How can it be avoided? How can it be resolved onceit occurs?
Deadlock occurs when two transactions are each waiting on a resource that the othertransaction holds. Deadlock
can be prevented by requiring transactions to acquire alllocks 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 transactionmay not see its own changes.Atomic means it is performed as a unit.
213)Under what conditions should indexes be used?
Indexes can be created to enforce uniqueness, to facilitate sorting, and to enable fastretrieval by column values.
A good candidate for an index is a column that is frequently used with equal conditions in WHERE clauses.
SQL is a language that provides an interface to RDBMS, developed by IBM. SQLSERVER is a RDBMS just like
Oracle, DB2.
215)What is Specialization?
It is the process of defining a set of subclasses of an entity type where each subclasscontain all the attributes and
relationships of the parent entity and may have additional attributes and relationships which are specific to itself.
216)What is generalization?
It is the process of finding common attributes and relations of a number of entitiesand defining a common
super class for them.
Proactive Update: The updates that are applied to database before it becomeseffective 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 timewhen 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 ofdisks against those in memory and microprocessor.
Raid technology employs the technique of data striping to achieve higher transfer rates.
A schedule S is serial if, for every transaction T participating in the schedule, all theoperations of T is executed
consecutively in the schedule, otherwise, the schedule iscalled non-serial schedule.
A schedule S of n transactions is serializable if it is equivalent to some serial scheduleof the same n transactions.
A key of a relation schema is called as a foreign key if it is the primary key ofsome other relation to
which it is related to.
223)What are the disadvantages of using a dbms?
227)What is schema?
The description of a data base is called the database schema , which is specified during
database design and is not expected to change frequently . A displayed schemais called
schema diagram .We call each object in the schema as schema construct.
----------------------0Ooooooo00000-------------------------------------