Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DBMS and Models

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

Question: - What is DBMS?

Explain Advantages, Disadvantages, Function,


Characteristics, Tools, Meta Data.

A Data Base Management System is system software for easy, efficient and reliable data
processing and management. It can be used for:
 Creation of a database.
 Retrieval of information from the database.
 Updating the database.
 Managing a database.

What is a Database?

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.

During early computer days, data was collected and stored on tapes, which were mostly write-
only, which means once data is stored on it, it can never be read again. They were slow and
bulky, and soon computer scientists realized that they needed a better solution to this problem.

Larry Ellison, the co-founder of Oracle was amongst the first few, who realized the need for
software based Database Management System.

A DBMS is software that allows creation, definition and manipulation of database, allowing
users to store, process and analyses data easily. DBMS provides us with an interface or a tool,
to perform various operations like creating database, storing data in it, updating data, creating
tables in the database and a lot more.

DBMS also provides protection and security to the databases. It also maintains data consistency
in case of multiple users.

Here are some examples of popular DBMS used these days:

 MySql
 Oracle
 SQL Server
 IBM DB2
 PostgreSQL
 Amazon Simple DB (cloud based) etc.

 Characteristics of Database Management System

A database management system has following characteristics:

1. Data stored into Tables: Data is never directly stored into the database. Data is stored into
tables, created inside the database. DBMS also allows having relationships between tables
which makes the data more meaningful and connected. You can easily understand what
type of data is stored where by looking at all the tables created in a database.
2. Reduced Redundancy: In the modern world hard drives are very cheap, but earlier when
hard drives were too expensive, unnecessary repetition of data in database was a big
problem. But DBMS follows Normalization which divides the data in such a way that
repetition is minimum.
3. Data Consistency: On Live data, i.e. data that is being continuously updated and added,
maintaining the consistency of data can become a challenge. But DBMS handles it all by
itself.
4. Support multiple user and Concurrent Access: DBMS allows multiple users to work on
it (update, insert, and delete data) at the same time and still manages to maintain the data
consistency.
5. Query Language: DBMS provides users with a simple Query language, using which data
can be easily fetched, inserted, deleted and updated in a database.
6. Security: The DBMS also takes care of the security of data, protecting the data from un-
authorized access. In a typical DBMS, we can create user accounts with different access
permissions, using which we can easily secure our data by restricting user access.
7. DBMS supports transactions, which allows us to better handle and manage data integrity
in real world applications where multi-threading is extensively used.

Disadvantages of DBMS

 Complexity: DBMS can be complex to set up and maintain, requiring specialized


knowledge and skills.

 Performance overhead: The use of a DBMS can add overhead to the performance of
an application, especially in cases where high levels of concurrency are required.

 Complex Design: Database design is complex, difficult and time consuming.


 Security: A DBMS can be vulnerable to security breaches if not properly configured
and managed. This can lead to data loss or theft.

 Cost: The cost of purchasing, maintaining and upgrading a DBMS can be high,
especially for large or complex systems.

 Damaged Part: If one part of database is corrupted or damaged, then entire database
may get affected.

 Compatibility: DBMS software may not be compatible with other software systems or
platforms, making it difficult to integrate with other applications.
Applications of DBMS

 Enterprise Information: Sales, accounting, human resources, Manufacturing, online


retailers.

 Banking and Finance Sector: Banks maintaining the customer details, accounts,
loans, banking transactions, credit card transactions. Finance: Storing the information
about sales and holdings, purchasing of financial stocks and bonds.

 University: Maintaining the information about student course enrolled information,


student grades, staff roles.

 Airlines: Reservations and schedules.

 Telecommunications: Prepaid, postpaid bills maintance.


Components of DBMS

The database management system can be divided into five major components, they are:

1. Hardware
2. Software
3. Data
4. Procedures
5. Database Access Language

Let's have a simple diagram to see how they all fit together to form a database management
system.
Question: - Difference Between File system and DBMS.

Basics File System DBMS

The file system is a way of


DBMS is software for managing the
arranging the files in a storage
database.
Structure medium within a computer.

Data Redundant data can be present in a


In DBMS there is no redundant data.
Redundancy file system.

It doesn’t provide Inbuilt


It provides in house tools for backup
Backup and mechanism for backup and
and recovery of data even if it is lost.
Recovery recovery of data if it is lost.

Query There is no efficient query Efficient query processing is there


processing processing in the file system. in DBMS.

There is more data consistency


There is less data consistency in
because of the process
the file system.
Consistency of normalization .

It is less complex as compared to It has more complexity in handling


Complexity DBMS. as compared to the file system.

DBMS has more security


File systems provide less security
Security mechanisms as compared to file
in comparison to DBMS.
Constraints systems.
It has a comparatively higher cost
It is less expensive than DBMS.
Cost than a file system.

In DBMS data independence exists,


mainly of two types:
There is no data independence.
1) Logical Data Independence .
Data
Independence 2)Physical Data Independence.

Only one user can access data at a Multiple users can access data at a
User Access time. time.

The users are not required to write The user has to write procedures for
Meaning procedures. managing databases

Data is distributed in many files. Due to centralized nature data


Sharing So, it is not easy to share data. sharing is easy
Question: - What is DBMS? Explain in File Processing system.
In the earlier age the computer system was used to store business records and produce different
information. They were generally faster and more accurate than equivalent manual systems.
These systems stored groups of records in separate file and so they were called file
processing system.

In a typical file processing system, each department has its own files, designed especially for
those applications. The department itself works with the data processing staff, sets policies or
standards for the format and maintenance of its files.

Disadvantages of File processing system

1) Data redundancy

In computer system many files are likely in the different formats and the programs are written
in different programming languages. Moreover, the same information may be duplicated in
several files, this duplication of data is known as data redundancy.

Example: If you store the same data item more than once in a database, that is data redundancy

2) Data inconsistency

Various copies contain the same type of data which may no longer which means that various
copies of same data may contain different kind of information.

Example: For example, if a student’s record in the database has 2 home telephone numbers;
consumers of the data will be unable to determine which phone numbers to use.

3) Difficulty in accessing data

In file processing system it is very difficult to access the data in a specific way and it also
require a special application program which carry out new task.

Question: - What is DBMS? Explain DDL and DML.


Data Definition Language (DDL)

DDL is the short name for Data Definition Language, which deals with database schemas and
descriptions, of how the data should reside in the database.

 CREATE: to create a database and its objects like (table, index, views, store procedure,
function, and triggers)

 ALTER: alters the structure of the existing database

 DROP: delete objects from the database

 TRUNCATE: remove all records from a table, including all spaces allocated for the
records are removed

 COMMENT: add comments to the data dictionary

 RENAME: rename an object

Data Manipulation Language (DML)

DML is the short name for Data Manipulation Language which deals with data manipulation
and includes most common SQL statements such SELECT, INSERT, UPDATE, DELETE, etc.,
and it is used to store, modify, retrieve, delete and update data in a database. Data query
language(DQL) is the subset of “Data Manipulation Language”. The most common command
of DQL is SELECT statement. SELECT statement help on retrieving the data from the table
without changing anything in the table.

 SELECT: retrieve data from a database

 INSERT: insert data into a table

 UPDATE: updates existing data within a table

 DELETE: Delete all records from a database table

 MERGE: UPSERT operation (insert or update)

 CALL: call a PL/SQL or Java subprogram

 EXPLAIN PLAN: interpretation of the data access path

 LOCK TABLE: concurrency Control

Question: - DATA Models?


A Database model defines the logical design and structure of a database and defines how
data will be stored, accessed and updated in a database management system. While
the Relational Model is the most widely used database model, there are other models too:

Data model category:-

1. Object based logical model: - These model are used in describing data at logical and
view levels.

Entity-relationship Model

Object oriented model


2. Record based logical model: -

Hierarchical Model
Network Model
Relational Model

3. Physical data model: - describe the behaviour of the data at the disk level.

ER Model (Entity Relationship Model): -

The Entity Relationship Model is a model for identifying entities to be represented in the
database and representation of how those entities are related. The ER data model specifies
enterprise schema that represents the overall logical structure of a database graphically.

Peter Chen developed the ER diagram in 1976. The ER model was created to provide a simple
and understandable model for representing the structure and logic of databases.

Why Use ER Diagrams In DBMS?

 ER diagrams represent the E-R model in a database, making them easy to convert into
relations (tables).

 ER diagrams provide the purpose of real-world modelling of objects which makes them
intently useful.

 ER diagrams require no technical knowledge and no hardware support.


 These diagrams are very easy to understand and easy to create even for a naive user.

 It gives a standard solution for visualizing the data logically.

Symbols Used in ER Model

ER Model is used to model the logical view of the system from a data perspective which
consists of these symbols:

 Rectangles: Rectangles represent Entities in the ER Model.

 Ellipses: Ellipses represent Attributes in the ER Model.

 Diamond: Diamonds represent Relationships among Entities.

 Lines: Lines represent attributes to entities and entity sets with other relationship types.

 Double Ellipse: Double Ellipses represent Multi-Valued Attributes.

 Double Rectangle: Double Rectangle represents a Weak Entity.


Components of ER Diagram

ER Model consists of Entities, Attributes, and Relationships among Entities in a Database


System.

What is Entity?

An Entity may be an object with a physical existence – a particular person, car, house, or
employee – or it may be an object with a conceptual existence – a company, a job, or a
university course.

Types of Entity

There are two types of entity:

1. Strong Entity

A Strong Entity is a type of entity that has a key Attribute. Strong Entity does not depend on
other Entity in the Schema. It has a primary key, that helps in identifying it uniquely, and it is
represented by a rectangle. These are called Strong Entity Types.

2. Weak Entity

An Entity type has a key attribute that uniquely identifies each entity in the entity set. But some
entity type exists for which key attributes can’t be defined. These are called Weak Entity types .

For Example, A company may store the information of dependents (Parents, Children,
Spouse) of an Employee. But the dependents can’t exist without the employee. So Dependent
will be a Weak Entity Type and Employee will be Identifying Entity type for Dependent,
which means it is Strong Entity Type .
What is Attributes?

Attributes are the properties that define the entity type. For example, Roll_No, Name, DOB,
Age, Address, and Mobile_No are the attributes that define entity type Student. In ER diagram,
the attribute is represented by an oval.

Attribute

Types of Attributes

1. Key Attribute

The attribute which uniquely identifies each entity in the entity set is called the key attribute.
For example, Roll_No will be unique for each student. In ER diagram, the key attribute is
represented by an oval with underlying lines.

Key Attribute

2. Composite Attribute
An attribute composed of many other attributes is called a composite attribute. For example,
the Address attribute of the student Entity type consists of Street, City, State, and Country. In
ER diagram, the composite attribute is represented by an oval comprising of ovals.

Composite Attribute

3. Multivalued Attribute

An attribute consisting of more than one value for a given entity. For example, Phone_No (can
be more than one for a given student). In ER diagram, a multivalued attribute is represented by
a double oval.

Multivalued Attribute

4. Derived Attribute

An attribute that can be derived from other attributes of the entity type is known as a derived
attribute. e.g.; Age (can be derived from DOB). In ER diagram, the derived attribute is
represented by a dashed oval.
Derived Attribute

The Complete Entity Type Student with its Attributes can be represented as:

Entity and Attributes

What is Cardinality OR Relationship?

The number of times an entity of an entity set participates in a relationship set is known
as cardinality . Cardinality can be of different types:

1. One-to-One: When each entity in each entity set can take part only once in the relationship,
the cardinality is one-to-one. Let us assume that a male can marry one female and a female can
marry one male. So the relationship will be one-to-one.

.
one to one cardinality

2. One-to-Many: In one-to-many mapping as well where each entity can be related to more
than one entity and the total number of tables that can be used in this is 2. Let us assume that
one surgeon department can accommodate many doctors. So the Cardinality will be 1 to M. It
means one department has many Doctors.

3. Many-to-One: When entities in one entity set can take part only once in the relationship set
and entities in other entity sets can take part more than once in the relationship set, cardinality
is many to one. Let us assume that a student can take only one course but one course can be
taken by many students. So the cardinality will be n to 1. It means that for one course there can
be n students but for one student, there will be only one course.

4. Many-to-Many: When entities in all entity sets can take part more than once in the
relationship cardinality is many to many. Let us assume that a student can take more than one
course and one course can be taken by many students. So the relationship will be many to many.
Hierarchical Model

This database model organizes data into a tree-like-structure, with a single root, to which all
the other data is linked. The hierarchy starts from the Root data, and expands like a tree, adding
child nodes to the parent nodes.

In this model, a child node will only have a single parent node.

This model efficiently describes many real-world relationships like index of a book, recipes
etc.

In hierarchical model, data is organised into tree-like structure with one one-to-many
relationship between two different types of data, for example, one department can have
many courses, many professors and of-course many students.
Network Model

(Network Data Model)

What is the database network model?


When we want to design the database, there is a variety of database models. Relational,
hierarchical and network models are famous models.. The network database model is a model
for modeling the entities in such a way that one child entity can have more than one parent
entities.

Example of a network model

Figure: a network model


In this figure, we can see that the subject is the child class and student and degree are the
parent classes.

So, the subject has two parent classes. STUDENT has one child and Degree class also have
one child.
This kind of relationship among entities represents the network model.
Characteristics of the network model
There are many characteristics of the network model, some of these characteristics are
mentioned below;
1. The network model is better than a hierarchical model.
2. Supports many to many relationships.
3. Many parents can have many children.
4. Many children can have many parents (as shown in the figure).
5. Entities are represented as a connected network with each other.
6. One child entity can have more than one parent entity
7. Represented as a network and one child can have more than one parent. This model
represents a complex structure.
8. Entities can have multiple parent entities and leads to a complex structure.
9. Not very flexible to reorganize the model.
10. High performance
11. Query facility is not available in the network model.

Relational Model in DBMS

Relational model makes the query much easier than in hierarchical or network database
systems. In 1970, E.F Codd has been developed it. A relational database is defined as a group
of independent tables which are linked to each other using some common fields of each related
table. This model can be represented as a table with columns and rows. Each row is known as
a tuple. Each table of the column has a name or attribute. It is well knows in database
technology because it is usually used to represent real-world objects and the relationships
between them. Some popular relational databases are used nowadays like Oracle, Sybase, DB2,
MySQL Server etc.

Relational Model Terminologies:

Following are the terminologies of Relational Model:

Relation Table

Tuple Row, Record

Attribute Column, Field

Domain It consists of set of legal values


Cardinality It consists of number of rows

Degree It contains number of columns

Operations on Relational Model:

List of the following basic operations that can be performed on a relational model:

o Insertion Operation

o Deletion Operation

o Update Operation

o Retrieval Operation
Types of key in DBMS:-

For example: In Student table, ID is used as a key because it is unique for each student. In
PERSON table, passport_number, license_number, SSN are keys since they are unique for
each person.
1. Primary key
o It is the first key which is used to identify one and only one instance of an entity
uniquely. An entity can contain multiple keys as we saw in PERSON table. The key
which is most suitable from those lists become a primary key.
o In the EMPLOYEE table, ID can be primary key since it is unique for each employee.
In the EMPLOYEE table, we can even select License_Number and Passport_Number
as primary key since they are also unique.

o For each entity, selection of the primary key is based on requirement and
developers.

2. Candidate key
o A candidate key is an attribute or set of an attribute which can uniquely identify a tuple.
o The remaining attributes except for primary key are considered as a candidate key. The
candidate keys are as strong as the primary key.
o

For example: In the EMPLOYEE table, id is best suited for the primary key. Rest of the
attributes like SSN, Passport_Number, and License_Number, etc. are considered as a candidate
key.
3. Super Key

Super key is a set of an attribute which can uniquely identify a tuple. Super key is a superset
of a candidate key.

For example: In the above EMPLOYEE table, for (EMPLOEE_ID, EMPLOYEE_NAME)


the name of two employees can be the same, but their EMPLYEE_ID can't be the same. Hence,
this combination can also be a key.

The super key would be EMPLOYEE-ID, (EMPLOYEE_ID, EMPLOYEE-NAME), etc.

4. Foreign key
o Foreign keys are the column of the table which is used to point to the primary key of
another table.
o In a company, every employee works in a specific department, and employee and
department are two different entities. So we can't store the information of the
department in the employee table. That's why we link these two tables through the
primary key of one table.
o We add the primary key of the DEPARTMENT table, Department_Id as a new attribute
in the EMPLOYEE table.
o Now in the EMPLOYEE table, Department_Id is the foreign key, and both the tables
are related.
BY ONE EXAMPLE SHOW THREE DIFFERENT KEYS:-

1. Primary Key

The primary key refers to a column or a set of columns of a table that helps us identify all the
records uniquely present in that table. A table can consist of just one primary key. Also, this
primary key cannot consist of the same values reappearing/repeating for any of its rows. All
the values of a primary key have to be different, and there should be no repetitions.
2. Super Key

A super key refers to the set of all those keys that help us uniquely identify all the rows present
in a table. It means that all of these columns present in a table that can identify the columns of
that table uniquely act as the super keys.

3. Candidate Key

The candidate keys refer to those attributes that identify rows uniquely in a table. In a table, we
select the primary key from a candidate key. Thus, a candidate key has similar properties as
that of the primary keys that we have explained above. In a table, there can be multiple
candidate keys.

4. Foreign Key

We use a foreign key to establish relationships between two available tables. The foreign key
would require every value present in a column/set of columns to match the referential table’s
primary key. A foreign key helps us to maintain data as well as referential integrity.

You might also like