Interview Questions and Answers On Database Basics
Interview Questions and Answers On Database Basics
Interview Questions and Answers On Database Basics
1. What is DBMS ?
The database management system is a collection of programs that enables user
to store, retrieve, update and delete information from a database.
2. What is RDBMS ?
Relational Database Management system (RDBMS) is a database management
system (DBMS) that is based on the relational model. Data from relational
database can be accessed or reassembled in many different ways without having
to reorganize the database tables. Data from relational database can be
accessed using an API , Structured Query Language (SQL).
3. What is SQL ?
Structured Query Language(SQL) is a language designed specifically for
communicating with databases. SQL is an ANSI (American National Standards
Institute) standard.
2. SQL is easy to learn. The statements are all made up of descriptive English
words, and there aren't that many of them.
3. SQL is actually a very powerful language and by using its language elements
you can perform very complex and sophisticated database operations.
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.
2. Exclusive Lock
When an exclusive lock is applied on data item, other transactions can't read or
write into the data item.
A relation is said to be in 2NF if and only if it is in 1NF and every non key
attribute is fully dependent on the primary key. After 2NF, we can still have
redundant data.
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.
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.
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.
data from related tables. "Join" return rows when there is at least one match in
both table. Type of joins are
Right Join
Return all rows from the right table, even if there are no matches in the left table.
Outer Join
Left Join
Return all rows from the left table, even if there are no matches in the right table.
Full Join
Return rows when there is a match in one of the tables.
24. What is Self-Join?
Self-join is query used to join a table to itself. Aliases should be used for the
same table comparison.
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.
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.