Q Define Database, Data, DBMS, State Purpose of Database

You might also like

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

Q Define database ,data, dbms ,state purpose of database

Data : Data is nothing but facts and statistics stored or free flowing over a
network, generally it's raw and unprocessed. For example: When you visit any
website, they might store you IP address, that is data, in return they
might add a cookie in your browser, marking you that you visited the
website, that is data, your name, it's data, your age, it's data.

Database : Database is a collection of inter-related data which helps in


efficient retrieval, insertion and deletion of data from database and organizes
the data in the form of tables, views, schemas, reports etc. For Example,
university database organizes the data about students, faculty, and admin
staff etc. which helps in efficient retrieval, insertion and deletion of data from
it. A Database is a collection of related data organized in a way that data can
be easily accessed, managed and updated. Database can be software based
or hardware based, with one sole purpose, storing data.

DataBase Management System : Database Management System


(DBMS)is a software for storing and retrieving users’ data while considering
appropriate security measures. It consists of a group of programs which
manipulate the database. The DBMS accepts the request for data from an
application and instructs the operating system to provide the specific data. In
large systems, a DBMS helps users and other third-party software to store
and retrieve data .DBMS allows users to create their own databases as per
their requirement. The term “DBMS” includes the user of the data base and
other application programs. It provides an interface between the data
and the software application.

Purpose DBMS : Programming Languages Like Python, Java .Net are


used to develop customized software. Every software or application has its
data to be stored permanently. Programming Language cannot store data
permanently. For this purpose we have to use DBMS. DBMS play significant
role in managing the data. It is a collection of programs that enables the 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.

Q State advantages of dbms and disadvantage of file processing system


Disadvantages in File Processing
1.Data redundancy is found-the presence of duplicate data in multiple data
files e.g. Customer Name, NI number, Address is present in several different
files on several different systems. Errors are generated, time entering
data is wasted, computer resources are needlessly taken up and updates can
be an enormous problem.
2.Data inconsistency will become a problem e. g. information is
duplicated in each system and may be updated in most systems but not
necessarily in all –the savings account and loan account may have
different addresses for a particular customer.
3.Lack of data independence. (Data dependence refers to the close
relationship between data stored in files and the specific software
programs needed to update and maintain those files). In the bank
imagine cases where any change in data format or structure requires a
change in all the programs that access the data. e.g. effort required to change
from 3-digit STD to 4-digit STD may be very difficult.
4.Data lacks integrity, i.e. this is the quality by which information from the
system can be trusted. The problems already stated show that
information can be out of date, can have different values in different
parts of the system, can be inaccurate etc.
5.Lack of flexibility i.e. creating reports, e.g. in this system a summary of
account balances in each separate account would require separate
reports for each open account or cutting and pasting into a word
processor file –not a satisfactory state of affairs.
6.Data not share able .Similarly if different departments want to access
data this would be very awkward.
Advantages of DBMS : Because information is so important in most
organizations, computer scientists have developed a large body of concepts
and techniques for managing data. These concepts and technique form the
focus of this book.
•Data Independence.
•Efficient Data Access.
•Data Integrity and security.
•Data administration.
•Concurrent access and Crash recovery.
•Reduced Application Development Time.

Q list and explain different types of user in dbms


Users of DBMS
Database users are categorized based up on their interactionwith the data base.
These are seven types of data base usersin DBMS.
1.DatabaseAdministrator(DBA): Database Administrator (DBA) is a person/team
who defines the schema and also controls the 3 levels of database. The DBA will
then create a new account id and password for the user if he/she need to access the
data base. DBA is also responsible for providing security to the data base and he
allows only the authorized users to access/modify the data base.
•DBA also monitors the recovery and back up and provide technical support.
•The DBA has a DBA account in the DBMS which called a system or superuser
account.
•DBA repairs damage caused due to hardware and/or software failures.

2.Naive/Parametric End Users :


Parametric End Users are the unsophisticated who don’t have any DBMS
knowledge but they frequently use the data base applications in their daily life to get
the desired results.
For examples, Railway’s ticket booking users are naive users. Clerks in any bank is
a naive user because they don’t have any DBMS knowledge but they still use the
database and perform their given task.
3.SystemAnalyst:
System Analyst is a user who analyses the requirements of parametric end users.
They check whether all the requirements of end users are satisfied.
4.SophisticatedUsers:
Sophisticated users can be engineers, scientists, business analyst, who are familiar
with the database. They can develop their own data base applications according to
their requirement. They don’t write the program code but they interact the data base
by writing SQL queries directly through the query processor.
5.DataBaseDesigners:
Data Base Designers are the users who design the structure of data base which
includes tables, indexes, views, constraints, triggers, stored procedures. He/she
controls what data must be stored and how the data items to be related.
6.Application Program:
Application Program are the back end programmers who writes the code for the
application programs. They are the computer professionals. These programs could
be written in Programming languages such as Visual Basic, Developer, C,
FORTRAN, COBOL etc.
7.CasualUsers/Temporary Users:
Casual Users are the users who occasionally use/access the data base but each
time when they access the data base they require the new information, for example,
Middle or higher level manager.
Q. Explain level of abstraction
Data Abstraction refers to the process of hiding irrelevant details from the user.
There are mainly three levels of data abstraction and we divide it into three levels in
order to achieve Data Independence. Data Independence means users and data
should not directly interact with each other. The user should be at a different level
and the data should be present at some other level. By doing so, Data Independence
can be achieved. Three levels of data abstraction:
1.View Level
2.Conceptual Level
3.Physical Level

Internal/Physical Level/Schema
The internal schema defines the physical storage structure of the
database. The internal schema is a very low-level representation of the entire
database. It contains multiple occurrences of multiple types of internal record. In the
ANSI term, it is also called “stored record’.
Facts about Internal schema:
•The internal schema is the lowest level of data abstraction
•It helps you to keeps information about the actual representation of the entire
database. Like the actual storage of the data on the disk in the form of records
• The internal view tells us what data is stored in the database and how
• It never deals with the physical devices. Instead, internal schema views a physical
device as a collection of physical pages
Conceptual Schema/Level
The conceptual schema describes the Database structure of the whole database for
the community of users. This schema hides information about the physical storage
structures and focuses on describing data types, entities, relationships, etc. This
logical level comes between the user level and physical storage view. However,
there is only single conceptual view of a single database.
Facts about Conceptual schema:
•Defines all database entities, their attributes, and their relationships
• Security and integrity information
•In the conceptual level, the data available to a user must be contained in or
derivable from the physical level
External Schema/User Level :
An external schema describes the part of the database which specific user is
interested in. It hides the unrelated details of the database from the user.
There may be “n” number of external views for each database .Each external view
is defined using an external schema, which consists of definitions of various
types of external record of that specific view. An external view is just the content
of the database as it is seen by some specific particular user. For example, a
user from the sales department will see only sales related data.
Facts about external schema:
•An external level is only related to the data which is viewed by specific end users
.•This level includes some external schemas.
•External schema level is nearest to the user
•The external schema describes the segment of the database which is needed for a
certain user group and hides the remaining details from the database from the
specific user group
Q SN on data independence
Data Independence is defined as a property of DBMS that helps you to change the
Database schema at one level of a database system without requiring to change the
schema at the next higher level. Data independence helps you to keep data
separated from all programs that make use of it. You can use this stored data for
computing and presentation. In many systems, data independence is an essential
function for components of the system.
Types of Data Independence
In DBMS there are two types of data independence
1.Physical data independence
2.Logical data independence
Physical Data Independence
Physical data independence helps you to separate conceptual levels from the
internal/physical levels. It allows you to provide a logical description of the database
without the need to specify physical structures. Compared to Logical Independence,
it is easy to achieve physical data independence. With Physical independence, you
can easily change the physical storage structures or devices with an effect on the
conceptual schema. Any change done would be absorbed by the mapping
between the conceptual and internal levels. Physical data independence is achieved
by the presence of the internal level of the database and then the transformation
from the conceptual level of the database to the internal level.
Examples of changes under Physical Data Independence
Due to Physical independence, any of the below change will not affect
the conceptual layer
.•Using a new storage device like Hard Drive or Magnetic Tapes
•Modifying the file organization technique in the Database
•Switching to different data structures.
•Changing the access method
.•Modifying indexes.
•Changes to compression techniques or hashing algorithms
.•Change of Location of Database from say C drive to D Drive

Logical Data Independence


Logical Data Independence is the ability to change the conceptual scheme without
changing
1.External views
2.External API or programs
Any change made will be absorbed by the mapping between external
and conceptual levels. When compared to Physical Data independence, it is
challenging to achieve logical data independence .
Examples of changes under Logical Data Independence
Due to Logical independence, any of the below change will not affect the
external layer.
1.Add/Modify/Delete a new attribute, entity or relationship is possible without a
rewrite of existing application programs
2.Merging two records into one
3.Breaking an existing record into two or more records

Q list and explain different tiers in dbms


➔ Users are differentiated by the way they expect to interact with the system:
Application programmers:
O Application programmers are computer professionals who write application
programs. Application programmers can choose from many tools to develop
user interfaces.
O Rapid application development (RAD) tools are tools that enable an application
programmer to construct forms and reports without writing a program.
Sophisticated users:
O Sophisticated users interact with the system without writing programs. Instead,
they form their requests in a database query language
o They submit each such query to a query processor, whose function is to break
down DML statements into instructions that the storage manager understands.
Specialized users :
O Specialized users are sophisticated users who write specialized
database applications that do not fit into the traditional data-processing framework.
O Among these applications are computer-aided design systems, knowledge base
and expert systems, systems that store data with complex data types (for
example, graphics data and audio data), and environment- modelling systems.
Naïve users :
o Naive users are unsophisticated users who interact with the system by invoking
one of the application programs that have been written previously.
O For example, a bank teller who needs to transfer $50 from account A to account B
invokes a program called transfer. This program asks the teller for the amount of
money to be transferred, the account from which the money is to be
transferred, and the account to which the money is to be transferred.

Q. Explain architecture of database administrator


→ Database Architecture
A Database Architecture is a representation of DBMS design. It helps to
design, develop, implement, and maintain the database management system. A
DBMS architecture allows dividing the database system into individual
components that can be independently modified, changed, replaced, and
altered. It also helps to understand the components of a database. A Database
stores critical information and helps access data quickly and securely.
Therefore, selecting the correct Architecture of DBMS helps in easy and efficient
data management.
Types of DBMS Architecture
There are mainly three types of DBMS architecture:
•One Tier Architecture (Single Tier Architecture)
•Two Tier Architecture
•Three Tier Architecture

1-Tier Architecture
1 Tier Architecture in DBMS is the simplest architecture of Database in which the
client, server, and Database all reside on the same machine. A simple one tier
architecture example would be anytime you install a Database in your system and
access it to practice SQL queries. But such architecture is rarely used in production.

2-Tier Architecture
A2 Tier Architecture in DBMS is a Database architecture where the presentation
layer runs on a client (PC, Mobile, Tablet, etc.), and data is stored on a server called
the second tier. Two tier architecture provides added security to the DBMS as it is
not exposed to the end-user directly. It also provides direct and faster
communication.

In the above 2 Tier client-server architecture of database management system, we


can see that one server is connected with clients 1, 2, and 3.
Two Tier Architecture Example:
A Contact Management System created using MS-Access.

3-Tier Architecture
A3 Tier Architecture in DBMS is the most popular client server architecture in DBMS
in which the development and maintenance of functional processes, logic, data
access, data storage, and user interface is done independently as separate
modules.
Three Tier architecture contains a presentation layer, an application layer, and a
database server.3-Tier database Architecture design is an extension of the 2-tier
client-server architecture. A 3-tier architecture has the following layers:
1.Presentation layer (your PC, Tablet, Mobile, etc.)
2.Application layer (server)
3.Database Server
The Application layer resides between the user and the DBMS, which is responsible
for communicating the user’s request to the DBMS system and send the response
from the DBMS to the user. The application layer(business logic layer) also
processes functional logic, constraint, and rules before passing data to the user or
down to the DBMS.
The goal of Three Tier client-server architecture is:
•To separate the user applications and physical database
•To support DBMS characteristics
•Program-data independence
•Supporting multiple views of the data

Three Tier Architecture Example:


Any large website on the internet like Flipkart ,Amazon ,Myntra etc

Q Functions of database architecture (DBA)


➔ 1. Schema Definition
•The DBA definition the logical Schema of the database. A Schema refers to
the overall logical structure of the database.
•According to this schema, database will be developed to store required data
for an organization.

2. Storage Structure and Access Method Definition


•The DBA decides how the data is to be represented in the stored database.

3. Assisting Application Programmers


•The DBA provides assistance to application programmers to develop
application programs.

4. Physical Organization Modification


•The DBA modifies the physical organization of the database to reflect the
changing needs of the organization or to improve performance.
5. Approving Data Access
•The DBA determines which user needs access to which part of the database.
•According to this, various types of authorizations are granted to different
users.

6. Monitoring Performance
•The DBA monitors performance of the system. The DBA ensures that better
performance is maintained by making changes in physical or logical schema if
required.
7. Backup and Recovery
•Database should not be lost or damaged.
•The DBA ensures this periodically backing up the database on magnetic
tapes or remote servers.
•In case of failure, such as virus attack database is recovered from this
backup.

Q what is SQL .State its characteristics and advantages


O SQL stands for Structured Query Language. It is used for storing and managing
data in database management system /(Relational DMS).
O SQL was the first commercial language introduced for E.F Codd's Relational
model of database.
O It is a standard language for Relational Database System. It enables a user
to create, read, update and delete relational databases and tables.
O All the RDBMS like MySQL, Informix, Sybase, Oracle, MS Access and SQL
Server use SQL as their standard database language.
O SQL allows users to query the database in a number of ways, using English-like
statements.
Advantages :
1. Faster Query Processing –
Large amount of data is retrieved quickly and efficiently. Operations like
Insertion, deletion, manipulation of data is also done in almost no time.

2. No Coding Skills –
For data retrieval, large number of lines of code is not required. All basic
keywords such as SELECT, INSERT INTO, UPDATE, etc are used and
also the syntactical rules are not complex in SQL, which makes it a user-
friendly language.
3. Standardized Language –
Due to documentation and long establishment over years, it provides a
uniform platform worldwide to all its users.

4. Portable –
It can be used in programs in PCs, server, laptops independent of any
platform (Operating System, etc). Also, it can be embedded with other
applications as per need/requirement/use.

5. Interactive Language –
Easy to learn and understand, answers to complex queries can be
received in seconds.
Characteristics :

o SQL is easy to learn.


o SQL is used to access data from relational database management systems.
o SQL can execute queries against the database.
o SQL is used to describe the data.
o SQL is used to define the data in the database and manipulate it when needed.
o SQL is used to create and drop the database and table.
o SQL is used to create a view, stored procedure, function in a database.
o SQL allows users to set permissions on tables, procedures, and views.

Q. State different data types in SQL


A Data Type in SQL server is defined as the type of data that any column or variable
can store. It is a type of data that an object holds like integer, character,
string, etc. While creating any table or variable, in addition to specifying the
name, you also set the Type of Data it will store.
Data types mainly classified into three categories for every database.
O String Data types
O Numeric Data types

O Date and time Data types

String data base


Numeric Data types

Date and time Data types


Q. State and explain different types of commands in SQL
There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.
DDL: Data Definition Language
O This includes changes to the structure of the tablelike creation of table, altering
table, deleting a table etc.
o All DDL commands are auto-committed. That means it saves all the changes
permanently in the database.

DML: Data Manipulation Language


O DML commands are used for manipulating the data stored in the table and not the
table itself.
O DML commands are not auto-committed .It means changes are not permanent to
database, they can be rolled back.

TCL: Transaction Control Language


O These commands are to keep a check on other commands and their affect on the
database. These commands can annul changes made by other commands by rolling
the data back to its original state. It can also make any temporary change
permanent.

DCL: Data Control Language


O Data control language are the commands to grant and take back authority from
any database user.

DQL: Data Query Language


O Data query language is used to fetch data from tables based on conditions that
we can easily apply.
Q. Explain with example groupby ,orderby , having clause
Groupby :
The SQL GROUP BY clause is used in collaboration with the SELECT statement to
arrange identical data into groups. This GROUP BY clause follows the WHERE
clause in a SELECT statement and precedes the ORDER BY clause.

Syntax

The basic syntax of a GROUP BY clause is shown in the following code block. The
GROUP BY clause must follow the conditions in the WHERE clause and must
precede the ORDER BY clause if one is used.
SELECT column1, column2
FROM table_name
WHERE [ conditions ]
GROUP BY column1, column2
ORDER BY column1, column2
For eg :
If you want to know the total amount of the salary on each customer, then the GROUP
BY query would be as follows.
SQL> SELECT NAME, SUM(SALARY) FROM CUSTOMERS
GROUP BY NAME;

Orderby :
The SQL ORDER BY clause is used to sort the data in ascending or descending
order, based on one or more columns. Some databases sort the query results in an
ascending order by default.
You can use more than one column in the ORDER BY clause. Make sure whatever
column you are using to sort that column should be in the column-list.

Syntax

The basic syntax of the ORDER BY clause is as follows −


SELECT column-list
FROM table_name
[WHERE condition]
[ORDER BY column1, column2, .. columnN] [ASC | DESC];

For eg :
The following code block has an example, which would sort the result in an ascending
order by the NAME and the SALARY −
SQL> SELECT * FROM CUSTOMERS
ORDER BY NAME, SALARY;

Having clause
The HAVING Clause enables you to specify conditions that filter which group results
appear in the results.
The WHERE clause places conditions on the selected columns, whereas the
HAVING clause places conditions on groups created by the GROUP BY clause.

Syntax

The following code block shows the position of the HAVING Clause in a query.
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
The HAVING clause must follow the GROUP BY clause in a query and must also
precede the ORDER BY clause if used. The following code block has the syntax of
the SELECT statement including the HAVING clause −
SELECT column1, column2
FROM table1, table2
WHERE [ conditions ]
GROUP BY column1, column2
HAVING [ conditions ]
ORDER BY column1, column2

Example

Following is an example, which would display a record for a similar age count that
would be more than or equal to 2.
SQL > SELECT ID, NAME, AGE, ADDRESS, SALARY
FROM CUSTOMERS
GROUP BY age
HAVING COUNT(age) >= 2;

Q. List and explain different aggregate functions


Aggregate functions in DBMS take multiple rows from the table and return a value
according to the query.
All the aggregate functions are used in Select statement.
Syntax −
SELECT <FUNCTION NAME> (<PARAMETER>) FROM <TABLE NAME>
AVG Function
This function returns the average value of the numeric column that is supplied as a
parameter.
Example: Write a query to select average salary from employee table.
Select AVG(salary) from Employee
COUNT Function
The count function returns the number of rows in the result. It does not count the null
values.
Example: Write a query to return number of rows where salary > 20000.
Select COUNT(*) from Employee where Salary > 20000;
Types −

• COUNT(*): Counts all the number of rows of the table including null.

• COUNT( COLUMN_NAME): count number of non-null values in column.

• COUNT( DISTINCT COLUMN_NAME): count number of distinct values in a


column.
MAX Function
The MAX function is used to find maximum value in the column that is supplied as a
parameter. It can be used on any type of data.
Example − Write a query to find the maximum salary in employee table.
Select MAX(salary) from Employee
SUM Function
This function sums up the values in the column supplied as a parameter.
Example: Write a query to get the total salary of employees.
Select SUM(salary) from Employee
STDDEV Function
The STDDEV function is used to find standard deviation of the column specified as
argument.
Example − Write a query to find standard deviation of salary in Employee table.
Select STDDEV(salary) from Employee
VARIANCE Function
The VARIANCE Function is used to find variance of the column specified as argument.
Example −
Select VARIANCE(salary) from Employee

Q. What is constraint ,List and explain different types of


constraint
Constraints are the rules enforced on the data columns of a table. These are used to
limit the type of data that can go into a table. This ensures the accuracy and reliability
of the data in the database.
Constraints could be either on a column level or a table level. The column level
constraints are applied only to one column, whereas the table level constraints are
applied to the whole table.
Following are some of the most commonly used constraints available in SQL.
• NOT NULL Constraint − Ensures that a column cannot have NULL value.
• DEFAULT Constraint − Provides a default value for a column when none is
specified.
• UNIQUE Constraint − Ensures that all values in a column are different.
• PRIMARY Key − Uniquely identifies each row/record in a database table.
• FOREIGN Key − Uniquely identifies a row/record in any of the given database
table.
• CHECK Constraint − The CHECK constraint ensures that all the values in a
column satisfies certain conditions.
• INDEX − Used to create and retrieve data from the database very quickly.

You might also like