You are on page 1of 4

Important DBMS Questions : Conceptual

If you are a CS/IT student then surely you've used some DBMS in
your projects. Interviewers especially emphasize on your knowledge
of DBMS, because no matter what programming language you use,
you'll definitely have to deal with databases. It is important to know
about database queries, but some level of conceptual knowledge is
also expected of the candidates. This articles elaborates on some of
the most popular DBMS interview questions.

Primary key & Unique key


A table can have only one primary key, while more than one unique
keys are allowed in a table.
Primary key can not have Null value. Whereas Unique key may have
Null value, but only one Null value is allowed.

Primary key & Foreign key


A primary key is a field or combination of fields that uniquely
identify a record in a table, so that an individual record can be
located without confusion.
A foreign key (sometimes called a referencing key) is a key used
to link two tables together. Typically you take the primary key field
from one table and insert it into the other table where it becomes a
foreign key (it remains a primary key in the original table).

Super key & Candidate key


Super key stands for superset of a key.
A Super Key is a set of one or more attributes that are taken
collectively and can identify all other attributes uniquely.

Candidate Keys are super keys for which no proper subset is a


super key. In other words candidate keys are minimal super keys.

Inner Join, Outer Join & Self Join


Inner Join
Inner Join is also referred to as an EQUIJOIN.
The INNER JOIN creates a new result table by combining column
values of two tables based upon the join-predicate. The query
compares each row of first table with each row of second table to
find all pairs of rows which satisfy the join-predicate. When the joinpredicate is satisfied, column values for each matched pair of rows
of first and second table are combined into a result row.
Outer Join
Outer Join is of three types1. Left Outer Join or Left Join
2. RIght Outer Join or Right Join
3. Full Join

1. Left Join

The SQL LEFT JOIN returns all rows from the left table, even if
there are no matches in the right table. This means that if the ON
clause matches 0 (zero) records in right table, the join will still
return a row in the result, but with NULL in each column from right
table.
2. Right Join

The SQL RIGHT JOIN returns all rows from the right table, even if
there are no matches in the left table. This means that if the ON

clause matches 0 (zero) records in left table, the join will still return
a row in the result, but with NULL in each column from left table.
3. Full Join

The SQL FULL JOIN combines the results of both left and right
outer joins. The joined table will contain all records from both
tables, and fill in NULLs for missing matches on either side.
Self Join
The SQL SELF JOIN is used to join a table to itself as if the table
were two tables, temporarily renaming at least one table in the SQL
statement.

Also read : Frequently Asked SQL Queries


RDBMS & DBMS

Relationship among tables is maintained in a RDBMS whereas


this not the case DBMS as it is used to manage the database.
Data Redundancy is common in DBMS whereas Keys and
indexes are used in the RDBMS tables to avoid redundancy.
DBMS is used for simpler business applications whereas
RDBMS is used for more complex applications.
Although the foreign key concept is supported by both DBMS
and RDBMS but its only RDBMS that enforces the rules.
RDBMS solution is required by large sets of data whereas small
sets of data can be managed by DBMS.
RDBMS examples: Oracle ,MySQL,SQL SERVER,IBM DB2, IBM
Informite etc
DBMS examples: dBase, Microsoft Acces, LibreOffice Base,
FoxPro. etc

Delete vs Truncate vs Drop


The DELETE command is used to remove rows from a table. A
WHERE clause can be used to only remove some rows. If no WHERE

condition is specified, all rows will be removed. After performing a


DELETE operation you need to COMMIT or ROLLBACK the
transaction to make the change permanent or to undo it. Note that
this operation will cause all DELETE triggers on the table to fire.
TRUNCATE removes all rows from a table. The operation cannot be
rolled back and no triggers will be fired. As such, TRUCATE is faster
and doesn't use as much undo space as a DELETE.
The DROP command removes a table from the database. All the
tables' rows, indexes and privileges will also be removed. No DML
triggers will be fired. The operation cannot be rolled back.

Varchar vs Char vs Varchar2


CHAR should be used for storing fix length character strings.
String values will be space/blank padded before stored on disk. If
this type is used to store varibale length strings, it will waste a lot of
disk space.
Currently VARCHAR behaves exactly the same as VARCHAR2.
However, this type should not be used as it is reserved for future
usage. VARCHAR is reserved by Oracle to support distinction
between NULL and empty string in future, as ANSI standard
prescribes. VARCHAR2 does not distinguish between a NULL and
empty string, and never will.
VARCHAR2 is used to store variable length character strings.
The string value's length will be stored on disk with the value itself.
For more helpful interview preparation material visit FreakyFresher.

You might also like