Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

DBMS QUESTION BANK ANS

Q1 Describe database model for Database Management System.


Q2 .Explain Data Abstraction and Level of data abstraction
Ans :- Levels of abstraction for DBMS

Database systems include complex data structures. In terms of retrieval of data, reduce complexity
in terms of usability of users and in order to make the system efficient, developers use levels of
abstraction that hide irrelevant details from the users. Levels of abstraction simplify database
design.

Mainly there are three levels of abstraction for DBMS, which are as follows –

1. Physical or Internal Level


2. Logical or Conceptual Level
3. View or External Level

Physical or Internal Level

It is the lowest level of abstraction for DBMS which defines how the data is actually stored, it defines
data-structures to store data and access methods used by the database. Actually, it is decided by
developers or database application programmers how to store the data in the database.So, overall,
the entire database is described in this level that is physical or internal level. It is a very complex
level to understand. For example, customer's information is stored in tables and data is stored in the
form of blocks of storage such as bytes, gigabytes etc.

Logical or Conceptual Level

Logical level is the intermediate level or next higher level. It describes what data is stored in the
database and what relationship exists among those data. It tries to describe the entire or whole data
because it describes what tables to be created and what are the links among those tables that are
created.It is less complex than the physical level. Logical level is used by developers or database
administrators (DBA). So, overall, the logical level contains tables (fields and attributes) and
relationships among table attributes.

View or External Level

It is the highest level. In view level, there are different levels of views and every view only defines a
part of the entire data. It also simplifies interaction with the user and it provides many views or
multiple views of the same database.View level can be used by all users (all levels' users). This level
is the least complex and easy to understand.For example, a user can interact with a system using
GUI that is view level and can enter details at GUI or screen and the user does not know how data is
stored and what data is stored, this detail is hidden from the user.

Q3 Draw ER Diagram for college management system and write Design


Issues.
Ans :- Description of College Management System Database:

• The details of Library is store into the Library tablesrespective with all tables

• Each entity (Branch, Students, Managers, Books, Library) contains primary key and unique keys.
• The entity Students, Managers has binded with Library, Books entities with foreign key.There is
one-to-one and one-to-many relationships available between Managers, Issues, Branch, Library

• All the entities Library, Managers, Students, Branch are normalized and reduce duplicacy of
records

• We have implemented indexing on each tables of College Management System tables for fast
query execution.

Q4 Explain Aggregate Function in SQLwith example.


Ans :- An aggregate function in SQL returns one value after calculating multiple values of a column.
We often use aggregate functions with the GROUP BY and HAVING clauses of the SELECT statement.

Various types of SQL aggregate functions are:

Count()

Sum()

Avg()
Min()

Max()

COUNT() Function

The COUNT() function returns the number of rows in a database table.

Syntax:

COUNT(*)

Or

COUNT([ALLIDISTINCT] expression)

Example:

We will use the 'products' table from the sample database for our demonstration.

SELECT COUNT(product_id)

FROM Products;

Ans :-

SUM() Function

The SUM() function returns the total sum of a numeric column.


Syntax:

SUM() Or SUM([ALLIDISTINCT] expression)

Example:

The following SQL statement finds the sum of the "unit price" fields in the "products" table:

SELECT SUM(unit_price)

FROM products;

AVG() Function

The AVG() function calculates the average of a set of values.

Syntax:

AVG() Or AVG([ALLIDISTINCT] expression)

Example:

The following SQL command calculates the average quantity in stock.

SELECT AVG(quantity_in_stock)

FROM Products;

Ans:-

MIN() Function

The MIN() aggregate function returns the lowest value (minimum) in a set of non-NULL values.

Syntax:

MIN() Or MIN([ALLIDISTINCT] expression)

Example:

SELECT MIN(quantity_in_stock)
FROM products;

Ans:-

MAX() Function

The MAX() aggregate function returns the highest value (maximum) in a set of non-NULL values.

Syntax:

AVG() Or AVG([ALLIDISTINCT] expression)

Example:

The code depicted below will give us the maximum quantity in stock in the products table.

SELECT MAX(quantity_in_stock)

FROM products;

Ans:- 6

Q6 What is ER diagram? Explain Component of ER Diagram


Q7 EXPLAIN Built-in Function in SQLwith example.
A built-in function is a piece for programming that takes zero or more inputs and returns a value.
There are many built-in functions in SQL Server. Here we are discussing about string, date, and time
functions in SQL Server.

CHAR()

This function returns the character based on the ASCII code. It takes a numeric value as an argument
and returns the character.

For example: SELECT CHAR(65) AS [In CAHR Format]

Result: 'A' (ASCII code of "A" is 65)

ASCII()

ASCII (American Standard Code for Information Interchange) is a code that uses numbers to
represent characters. This function returns the ASCII value for the specific character. To get the ASCII
code of a character, we can call the ASCII() function. It takes a character as an argument and returns
the ASCII code of the character.

For example : SELECT ASCII('A') AS [In ASCII Format]

Result: '65’ (ASCII code of "A" is 65)

LEFT()

This function is used to get a number of characters from a string starting from left. This function
takes two arguments. The first argument specifies the original string and the second argument
specifies the number of characters from the most-left.
For example: SELECT LEFT('Amit Mohanty’ , 4) AS [Name];

Result: 'Amit' (We get only 4 character of the string)

LEN()

This function returns the length of a string. This function takes one argument as the string to be
considered.

For example: SELECT LEN(‘Amit Mohanty’) AS [Count1];

Result: '12' (Returns total character of the string including space)

Q8 Explain DDL Commands with Example


Ans:- DDL is an abbreviation of Data Definition Language.
The DDL Commands in Structured Query Language are used to create and modify the schema of

the database and its objects. The syntax of DDL commands is predefined for describing the data.

The commands of Data Definition Language deal with how the data should exist in the database.

Following are the five DDL commands in SQL:

1. CREATE Command :- CREATE is a DDL command used to create databases, tables, triggers
and other database objects. ( ex - Create Database Books;)

2. DROP Command :- DROP is a DDL command used to delete/remove the database objects
from the SQL database. We can easily remove the entire table, view, or index from the
database using this DDL command. (ex - DROP DATABASE Database_Name;)

3. . ALTER Command :- ALTER is a DDL command which changes or modifies the existing
structure of the database, and it also changes the schema of database objects.We can also
add and drop constraints of the table using the ALTER command. ( ex - ALTER
TABLE name_of_table ADD column_name column_definition;)

4. TRUNCATE Command :- TRUNCATE is another DDL command which deletes or removes all
the records from the table.This command also removes the space allocated for storing the
table records. ( ex - TRUNCATE TABLE Student;)

5. RENAME Command :- RENAME is a DDL command which is used to change the name of the
database table. ( ex - RENAME TABLE Old_Table_Name TO New_Table_Name;)

Q10 Explain DML Commands with Example.


Ans:- DML is an abbreviation of Data Manipulation Language. The DML commands in Structured
Query Language change the data present in the SQL database.We can easily access, store, modify,
update and delete the existing records from the database using DML commands.

Following are the four main DML commands in SQL:

1. SELECT command :- SELECT is the most important data manipulation command in Structured
Query Language. The SELECT command shows the records of the specified table. It also
shows the particular record of a particular column by using the WHERE clause.

( For Ex: SELECT column_Name_1, column_Name_2, ….., column_Name_N FROM Name_of_table;)

2. INSERT Command :- INSERT is another most important data manipulation command in


Structured Query Language,which allows users to insert data in database tables.

(For Ex:-
3. UPDATE Command :- UPDATE is another most important data manipulation command in
Structured Query Language,which allows users to update or modify the existing data in
database tables.

4. Delete command:- DELETE is a DML command which allows SQL users to remove single or
multiple existing records from the database tables.This command of Data Manipulation
Language does not delete the stored data permanently from the database. We use the
WHERE clause with the DELETE command to select specific rows from the table.
Syntax:- DELETE FROM Table_Name WHERE condition;

You might also like