0% found this document useful (0 votes)
13 views4 pages

DBMS Theory

dbms theory for interview

Uploaded by

Dhruv Sompura
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

DBMS Theory

dbms theory for interview

Uploaded by

Dhruv Sompura
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

DBMS theory

3 tier arch: physical(where data stored), conceptual(logical schema like tables and
their relationships), external(data abstraction-viewing data and tables for each
user)
this type or arch helps in scalability, readability, etc.

rdbms: tables, no sql: key value pairs

Types of keys?
A super key is a set of attributes of a relation schema upon which all attributes
of the schema are functionally dependent. No two rows can have the same value of
super key attributes. can be null
A Candidate key is a minimal superkey, i.e., no proper subset of Candidate key
attributes can be a superkey. can be null. can have multiple candidate keys but one
primary key. A candidate key, of a relational database is any set of columns that
have a unique combination of values in each row, with the additional constraint
that removing any column could produce duplicate combinations of values
A Primary Key is one of the candidate keys. One of the candidate keys is selected
as most important and becomes the primary key. There cannot be more than one
primary key in a table. cant be null
A Foreign key is a field (or collection of fields) in one table that uniquely
identifies a row of another table.
superkey ka subset candidate and candidate ka subset primary

Types of sql languages


DDL stands for Data Definition Language. SQL queries like CREATE, ALTER, DROP,
TRUNCATE and RENAME come under this.
DML stands for Data Manipulation Language. SQL queries like SELECT, INSERT, DELETE
and UPDATE come under this.
DCL stands for Data Control Language. SQL queries like GRANT and REVOKE come under
this.

Diff between having and where?


HAVING is used in an aggregate function. The WHERE clause selects before grouping.
The HAVING clause selects rows after grouping. Unlike the HAVING clause, the WHERE
clause cannot contain aggregate functions. The Where clause acts as a pre filter
where as Having as a post filter.

What is a view in SQL?


A view is a virtual table based on the result-set of an SQL statement. Hide
complexity of data. Can show aggregate tables or shorter version of tables.

Diff between drop, truncate and delete?


drop and truncate are ddl so cant be rolled back.
in drop tables are deleted permanently, truncate me data stored in table is deleted
but structure of table is preserved but can not roll back here also. delete
straightway deletes the whole row and can be rolled back but is slower than
truncate.

Join: joins tables based on common field

What is a stored procedure?


A stored procedure is like a function that contains a set of operations compiled
together. It contains a set of operations that are commonly used in an application
to do some common database tasks.

What is a Trigger?
A special type of stored procedure for insert, delete and update.
What is the difference between Trigger and Stored Procedure?
Stored Procedures are explicitly called and used for complex operations, while
Triggers are automatically invoked in response to specific database events to
enforce rules or automate actions.
Stored Procedures offer better control over execution and can be reused, but
Triggers provide automation and ensure consistency across database operations.

What is Identity?
Identity (or AutoNumber) is a column that automatically generates numeric values. A
start and increment value can be set, but most DBA leave these at 1. A GUID column
also generates numbers; the value of this cannot be controlled. Identity/GUID
columns do not need to be indexed.

What is a transaction? What are ACID properties?


A Database Transaction is a set of database operations that must be treated as a
whole, which means either all operations are executed or none of them. An example
can be a bank transaction from one account to another account. Either both debit
and credit operations must be executed or none of them. ACID (Atomicity,
Consistency, Isolation, Durability) is a set of properties that guarantee that
database transactions are processed reliably.

What are indexes?


A database index is a data structure that improves the speed of data retrieval
operations on a database table at the cost of additional writes and the use of more
storage space to maintain the extra copy of data. Data can be stored only in one
order on a disk. To support faster access according to different values, faster
search like binary search for different values is desired, For this purpose,
indexes are created on tables. These indexes need extra space on the disk, but they
allow faster search according to different frequently searched values.

What are clustered and non-clustered Indexes?


### Clustered Index:
- **Data Storage:** A clustered index determines the physical order of the data in
the table. Think of it like sorting the pages of a book by a specific topic—
everything is organized based on that order.
- **One per Table:** There can only be one clustered index per table because the
data can only be sorted in one way.
- **Faster Access to Data:** When you search for data using a clustered index, the
database goes directly to where the data is stored since it's already organized
that way.

### Non-Clustered Index:


- **Separate from Data:** A non-clustered index is like the index at the back of a
book. It has pointers (like page numbers) that tell you where to find the data, but
the data itself is stored elsewhere.
- **Multiple per Table:** You can have multiple non-clustered indexes on a table,
each helping you look up data in different ways.
- **Indirect Access:** When you search using a non-clustered index, the database
uses the index to find the pointers and then retrieves the data from its actual
location.

### Quick Summary:


- **Clustered Index:** Directly sorts and stores the data in the table. Only one
per table.
- **Non-Clustered Index:** Creates a separate structure to point to the data's
location. Multiple can exist per table.

What integrity rules exist in the DBMS?


Entity Integrity: Primary key can never have a NULL value.
Referential Integrity: Foreign key is a NULL value or it should be the primary key
of any other relation.

What is 1NF in the DBMS?


1NF is known as the First Normal Form.
The objective of this is to remove the duplicate columns that are present in the
table.

What is 2NF ke rules in DBMS?


A table is in the 1NF.
Each non-prime attribute of a table is said to be functionally dependent in
totality on the primary key.

What is 3NF ke rules in DBMS?


A table is in the 2NF.
Each non-prime attribute of a table is said to be non-transitively dependent on
every key of the table.

What is BCNF?
BCNF is the Boyce Codd Normal Form which is stricter than the 3NF.
2 conditions:
A table is in the 3NF.
For each of the functional dependencies X->Y that exists, X is the super key of a
table.

What is CLAUSE in SQL?


A clause in SQL is a part of a query that lets you filter or customize how you want
your data to be queried to you.

What is a Live Lock?


Livelock situation can be defined as when two or more processes continually repeat
the same interaction in response to changes in the other processes without doing
any useful work. These processes are not in the waiting state, and they are running
concurrently. This is different from a deadlock because in a deadlock all processes
are in the waiting state.

What is QBE?
Query-by-example represents a visual/graphical approach for accessing information
in a database through the use of query templates called skeleton tables.

Why are cursors necessary in embedded SQL?


A cursor is an object used to store the output of a query for row-by-row processing
by the application programs. SQL statements operate on a set of data and return a
set of data. On other hand, host language programs operate on a row at a time. The
cursors are used to navigate through a set of rows returned by an embedded SQL
SELECT statement. A cursor can be compared to a pointer.

What are the main differences between Primary key and Unique Key?
The main difference between the Primary key and the Unique key is that the Primary
key can never have a null value while the Unique key may consist of a null value.
In each table, there can be only one primary key while there can be more than one
unique key in a table.

Explain Entity, Entity Type, and Entity Set in DBMS?


The entity is an object, place, or thing which has its independent existence in the
real world and about which data can be stored in a database. For Example, any
person, book, etc.
Entity Type is a collection of entities that have the same attributes. For Example,
the STUDENT table contains rows in which each row is an entity holding the
attributes like name, age, and id of the students, hence STUDENT is an Entity Type
that holds the entities having the same attributes.
Entity Set is a collection of entities of the same type. For Example, A collection
of the employees of a firm.

What are the different levels of abstraction in the DBMS?


Physical Level: This is the lowest level of the data abstraction which states how
the data is stored in the database.
Logical Level: This is the next level of the data abstraction which states the type
of the data and the relationship among the data that is stored in the database.
View Level: This is the highest level in the data abstraction which shows/states
only a part of the database.

What is E-R model in the DBMS?


E-R model is known as an Entity-Relationship model

What is a functional dependency in the DBMS?


This is basically a constraint that is useful in describing the relationship among
the different attributes in a relation.
Example: If there is some relation ‘R1’ which has 2 attributes as Y and Z then the
functional dependency among these 2 attributes can be shown as Y->Z which states
that Z is functionally dependent on Y.

What are the different types of relationships in the DBMS


one to one, one to many and many to many

What are temporary tables? When are they useful?


Temporary tables exist solely for a particular session, or whose data persists for
the duration of the transaction.

You might also like