DBMS Assigment 1
DBMS Assigment 1
DBMS Assigment 1
Example
A small startup company and industries managing a huge amount of data becomes a mess.
So, software like DBMS brought a revolution in many fields regarding efficient information
management.
It is basically a set of programs which allow users to store, modify or update, and retrieve
information from the database as per the user requirements.
DBMS also provides security and protection to databases. It acts as a middle layer between
the database and user.
The different types of DBMS are My SQL, Oracle, MYSQL Server, Microsoft Access, SQL,
DB2 etc.
Functions of DBMS
The motive behind the development of the DBMS is to manage the information as a
whole.
Its main objective is to make the data easily accessible, rapid, less costly and flexible
for its users.
It removes the duplication of data and minimizes data redundancy.
The extra space covered by duplicate data is used for other purposes and there is no
wastage of space.
The DBMS is easy to use and learn.
DBMS packages are user-friendly and flexible.
There is data independence because the user can do changes at any level of the
database without impact on other levels like hardware and software processes.
DBMS is economically good for everyone.
Anyone can use, store and manipulate data at an affordable price.
It can be accessible by multiple users and helps to recover data in case it is not saved
by the user. The system can easily recover the data in no time and it maintains
accuracy and integrity.
It prevents unauthorized access to the data and the data remains private. Through
centralized control, DBMS makes it sure that proper security is provided to the data.
It is useful for retrieving, analyzing and storing the data.
Data Sharing:
In the normal file system, data sharing is too difficult because file sharing is a complex task.
In DBMS, all the data is centralized, so data sharing is a very easy task.
Data Concurrency:
When more than one user accesses the database simultaneously, then it is called concurrency.
In a file system, when multiple users are using the files at the same time, then there may be a
chance of anomalies in the data due to changes, and it does not provide any method to detect
anomalies. But in DBMS, we have a locking system to detect the anomalies so we can protect
the data.
Data Searching:
To search the data in a file system, we have to write a specific program and run it. In DBMS,
we have query languages by which we can write small queries to get the data we want from
the database. We can use various query languages, like MySQL, Oracle, etc., for a database
to search and retrieve the data.
Data Integrity:
When we insert new data into the database, we require some specific constraints on the data
like integer or not null, etc. The file system does not provide any system to check the
constraints, whereas DBMS has the functionality to check the constraints on the data, and it
allows user defined data types.
System Crashing:
There are various reasons by which our system can crash. Once a system crashes, the file
system loses all its files and data, and we can not recover it again. But DBMS has a recovery
manager which can recover the data if the system crashes.
Data Security:
In the file system, we have only password protection to save the files and data, but it is not
reliable. In DBMS, we have special algorithms and features to secure the data.
Backup:
For the backup of data, DBMS creates a subsystem, whereas the file system does not create
any system for data backup.
Interfaces:
DBMS provides various kinds of the interface to users like application interfaces, graphical
interfaces, etc.
Maintenance:
The file system is not maintained easily because it is decentralized, whereas DBMS is a
centralized system, so it becomes easy to maintain it.
Database design
Performance issues
Database accessibility
Capacity issues
Data replication
Table Maintenance
Responsibilities of DBA
The responsibilities of DBA are as follows −
Database designing.
Knowledge of Structured Query Language (SQL).
Know about distributed architecture.
Knowledge on different operating servers.
Idea on Relational Database Management System (RDBMS).
Ready to face challenges and solve the problems quickly.
4. Explain data model in detail ?
Data Model is the modeling of the data description, data semantics, and consistency constraints
of the data. It provides the conceptual tools for describing the design of a database at each level
of data abstraction. Therefore, there are following four data models used for understanding the
structure of the database
1) Relational Data Model: This type of model designs the data in the form of rows and
columns within a table. Thus, a relational model uses tables for representing data and in-
between relationships. Tables are also called relations. This model was initially described by
Edgar F. Codd, in 1969. The relational data model is the widely used model which is
primarily used by commercial data processing applications.
1-Tier Architecture
In this architecture, the database is directly available to the user. It means the user can
directly sit on the DBMS and uses it.
Any changes done here will directly be done on the database itself. It doesn't provide a
handy tool for end users.
The 1-Tier architecture is used for development of the local application, where programmers
can directly communicate with the database for the quick response.
2-Tier Architecture
3-Tier Architecture
The 3-Tier architecture contains another layer between the client and server. In this
architecture, client can't directly communicate with the server.
The application on the client-end interacts with an application server which further
communicates with the database system.
End user has no idea about the existence of the database beyond the application server. The
database also has no idea about any other user beyond the application.
The 3-Tier architecture is used in case of large web application.
Types of attributes
The different types of attributes are as follows −
Composite attribute
It can be divided into smaller sub parts, each sub part can form an independent attribute.
For example −
Name
FirstName MiddelName LastName
Simple or Atomic attribute
For example −
Phone number
PIN code
Attributes having a single value for a particular item is called a single valued attribute.
Multi-valued Attribute
Attribute having a set of values for a single entity is called a multi-valued attribute.
For example −
e-mail
Tel.No
Hobbies
When one attribute value is derived from the other is called a derived attribute.
Complex Attribute
For example
If a person has more than one house and each house has more than one phone. Then, that
attribute phone is represented as a complex attribute.
8. Explain how to create database & table use it ?
A table is used to organize data in the form of rows and columns and used for both storing
and displaying records in the structure format. It is similar to worksheets in the spreadsheet
application. A table creation command requires three things:
MySQL allows us to create a table into the database mainly in two ways:
MySQL allows us to create a table into the database by using the CREATE TABLE
command. Following is a generic syntax for creating a MySQL table in the database.
3. column_definition2,
4. ........,
5. table_constraints
6. );
1. Domain constraints
Domain constraints can be defined as the definition of a valid set of values for an attribute.
The data type of domain includes string, character, integer, time, date, currency, etc. The
value of the attribute must be available in the corresponding domain.
Example:
The entity integrity constraint states that primary key value can't be null.
This is because the primary key value is used to identify individual rows in relation and if the
primary key has a null value, then we can't identify those rows.
A table can contain a null value other than the primary key field.
Example:
Example:
4. Key constraints
Keys are the entity set that is used to identify an entity within its entity set uniquely.
An entity set can have multiple keys, but out of which one key will be the primary key. A
primary key can contain a unique and null value in the relational table.
Example:
SQL create table is used to create a table in the database. To define the table, you should
define the name of the table and also define its columns and column's data type.
Syntax
5. ...
6. "columnN" "data type");
Drop table
A SQL drop table is used to delete a table definition and all the data from a table. When this
command is executed, all the information available in the table is lost forever, so you have to
very careful while using this command.
Syntax
In SQL, DELETE statement is used to delete rows from a table. We can use WHERE
condition to delete a specific row from a table. If you want to delete all the records from the
table, then you don't need to use the WHERE clause.
Syntax
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.
1. SELECT Command
2. INSERT Command
3. UPDATE Command
4. DELETE Command
If we want to retrieve the data from all the columns of the table, we have to use the following
SELECT command:
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.
Count():
Sum():
sum(salary): Sum all Non Null values of Column salary i.e., 310
sum(Distinct salary): Sum of all distinct Non-Null values i.e., 250.
Avg():
Min(salary): Minimum value in the salary column except NULL i.e., 40.
Max(salary): Maximum value in the salary i.e., 80.