CS1202 Foc Unit-2
CS1202 Foc Unit-2
DATABASE
INTRODUCTION
Data: It is a collection of information. The facts that can be recorded and which have implicit
meaning known as 'data'.
File Processing System was first to replace non-computer based approach for maintaining
records. It was a successful System of its time and still there are many organizations that are
using File Processing System to maintain their data and information. But it is just not suitable for
handling data of big firms and organizations since it uses different files to store data. It has many
drawbacks and disadvantages that made it out of date.
1. Duplicate Data
Data is stored more than once in different files, that means duplicate data may occur in all these
files. Since all the files are independent on each other so it is very difficult to overcome this error
and if anyone finds this error then it will take time and effort to solve this issue.
2. Inconsistency
In file processing system, various copies of same data may contain different values. Data is not
consistent in this system; it means if a data item needs to be changed then all the files containing
that data need to be modified. It may create a risk of out dated values of data.
3. Accessing Anomalies
Accessing anomalies means that it is not easy to access data in a desired or efficient way. It
makes supervision of department very difficult. If a user wants information in a specific manner,
then he requires creating a program for it.
4. Poor Data Integrity
A collection of data is integrated if it meets certain consistency constraints. A programmer
always puts these constraints in the programs by adding some codes. In File Processing System,
poor data integrity often arises and it becomes very difficult to add new constraints at that time.
5. Poor Data Security
Poor data security is the most threatening problem in File Processing System. There is very less
security in File Processing System as anyone can easily modify and change the data stored in the
files. All the users must have some restriction of accessing data up to a level.
6. Atomicity Problem
Atomicity is required to save the data values; it means that information is completely entered or
canceled at all. Any system may fail at any time and at that time it is desired that data should be
in a consistent state.
7. Wastage of Labor and Space
Labor is very costly in this era and no organization can afford wastage of their precious labor.
File Processing System needs lots of copied data in different files that cause wastage of labor.
Also maintaining same data again and again leads to wastage of space too.
8. Data Isolation
Data is isolated in File Processing System and data is stored in different files. These files can be
in different formats. If you want to extract data from two file, then you are required to which part
of the file is needed and how they are related to each other.
But still in spite of so many disadvantages, File Processing System is still good for small
organizations because it does not require costly soft wares and programmers to handle it.
DATABASE
A database is an organized collection of data, generally stored and accessed electronically from a
computer system. It supports the storage and manipulation of data.
In other words, databases are used by an organization as a method of storing, managing and
retrieving information.
Types of Databases
Depending upon the usage requirements, there are following types of databases available in
the market:
● Centralized database
● Distributed database
● Personal database
● End-user database
● Commercial database
● NoSQL database
● Operational database
● Relational database
● Cloud database
● Object-oriented database
● Graph database
● Although databases allow businesses to store and access data efficiently, they also have
certain disadvantages
● Complexity
● Cost
● Security
● Compatibility
Examples of Databases
1. Oracle Database
2. Sybase
3. MySQL
CHARACTERISTICS OF DBMS
7. Data Persistence
Persistence means if the data is not removed explicitly then all the data will be maintained in
DBMS. If any system failure happens then life span of data stored in the DBMS will be decided
by the users directly or indirectly. Any data stored in the DBMS can never be lost. If system
failure happens in between any transaction then it will be rolled back or fully completed, but data
will never be at risk.
9. Data integrity
Users can have multiple views of database depending on their department and interest.
DBMS support multiple views of database to the users. For example, a user of the
teaching department will have different view and user of hostel department will have
different. This feature helps users to have somewhat security because users of other
departments cannot access their files.
A database management system should be able to store any kind of data. It should not be
restricted to employee name, salary, and address. Any kind of data that exists in the real
world can be stored in DBMS because we need to work with all kinds of data that is
present around us.
12. Security
DBMS provides security to the data stored in it because all users have different rights to
access database. Some of the users can access the whole database while other can access
a small part of database. For example, a computer network lecturer can only access files
that are related to computer subjects but HOD of the department can access files of all
subjects that are related to their department.
Key features:
● Represents the business data as seen in the real world and as understood by businesses.
● It facilitates an easy understanding of the business data, concepts, and rules.
● The contributors are generally Business stakeholders and Data Architects.
● It makes communication easy and clear as all stakeholders refer to specific entities with
the same nomenclature and thus reducing communication gaps.
● The main three components or elements of the Conceptual Data Model are
● Entity
● Attributes
● Relationship.
● This view, in a simple way, presents all the data entities referred to by the business and
their characteristics called attributes and the dependency or the connection between
entities called Relationship.
● In this data modeling, there are no details of the actual database or actual data that will be
stored.
Data model example:
● Customer and Product are two entities. Customer number and name are attributes of the
Customer entity
● Product name and price are attributes of product entity
● Sale is the relationship between the customer and product
Conceptual Data
Model
Characteristics of a conceptual data model
Conceptual data models known as Domain models create a common vocabulary for all
stakeholders by establishing basic concepts and scope.
Representation of Data Models
Data Model gives us an idea that how the final system will look like after its complete
implementation. It defines the data elements and the relationships between the data elements.
Data Models are used to show how data is stored, connected, accessed and updated in the
database management system. Here, we use a set of symbols and text to represent the
information so that members of the organisation can communicate and understand it. Though
there are many data models being used nowadays but the Relational model is the most widely
used model. Apart from the Relational model, there are many other types of data models about
which we will study in details in this blog. Some of the Data Models in DBMS are:
1. Hierarchical Model
2. Network Model
3. Entity-Relationship Model
4. Relational Model
Hierarchical Model
Hierarchical Model was the first DBMS model. This model organizes the data in the hierarchical
tree structure. The hierarchy starts from the root which has root data and then it expands in the
form of a tree adding child node to the parent node. This model easily represents some of the
real-world relationships like food recipes, sitemap of a website etc. Example: We can represent
the relationship between the shoes present on a shopping website in the following way:
1. One-to-many relationship: The data here is organized in a tree-like structure where the
one-to- many relationship is between the datatypes. Also, there can be only one path from
parent to any node. Example: In the above example, if we want to go to the
node sneakers we only have one path to reach there i.e. through men's shoes node.
2. Parent-Child Relationship: Each child node has a parent node but a parent node can
have more than one child node. Multiple parents are not allowed.
3. Deletion Proble m: If a parent node is deleted then the child node is automatically
deleted.
4. Pointe rs: Pointers are used to link the parent node with the child node and are used to
navigate between the stored data. Example: In the above example the 'shoes' node points
to the two other nodes 'women shoes' node and 'men's shoes' node.
● As it does not support more than one parent of the child node so if we have some
complex relationship where a child node needs to have two parent node then that can't be
represented using this model.
Network Model
This model is an extension of the hierarchical model. It was the most popular model before the
relational model. This model is the same as the hierarchical model, the only difference is that a
record can have more than one parent. It replaces the hierarchical tree with a graph. Example: In
the example below we can see that node student has two parents i.e. CSE Department and
Library. This was earlier not possible in the hierarchical model.
Features of a Network Model
1. Ability to Merge more Relationships: In this model, as there are more relationships so
data is more related. This model has the ability to manage one-to-one relationships as
well as many-to- many relationships.
2. Many paths: As there are more relationships so there can be more than one path to the
same record. This makes data access fast and simple.
3. Circular Linked List: The operations on the network model are do ne with the help of
the circular linked list. The current position is maintained with the help of a program and
this position navigates through the records according to the relationship.
● The data can be accessed faster as compared to the hierarchical model. This is because
the data is more related in the network model and there can be more than one path to
reach a particular node. So the data can be accessed in many ways.
● As more and more relationships need to be handled the system might get complex. So, a
user must be having detailed knowledge of the model to work with the model.
Entity-Relationship Model
Entity-Relationship Model or simply ER Model is a high- level data model diagram. In this
model, we represent the real-world problem in the pictorial form to make it easy for the
stakeholders to understand. It is also very easy for the developers to understand the system by
just looking at the ER diagram. We use the ER diagram as a visual tool to represent an ER
Model. ER diagram has the following three components:
● Relationship: Relationship tells how two attributes are related. Example: Teacher works
for a department.
Example:
In the above diagram, the entities are Teacher and Department. The attributes of Teacher entity
are Teacher_Name, Teacher_id, Age, Salary, Mobile_Number. The attributes of
entity Departme nt entity are Dept_id, Dept_name. The two entities are connected using the
relationship. Here, each teacher works for a department.
Features of ER Model
● Database Design: This model helps the database designers to build the database and is
widely used in database design.
Advantages of ER Model
● Effective Communication Tool: This model is used widely by the database designers for
communicating their ideas.
● Easy Conve rsion to any Model: This model maps well to the relational model and can
be easily converted relational model by converting the ER model to the table. This model
can also be converted to any other model like network model, hierarchical model etc.
Disadvantages of ER Model
Relational Model is the most widely used model. In this model, the data is maintained in the
form of a two-dimensional table. All the information is stored in the form of row and columns.
The basic structure of a relational model is tables. So, the tables are also called relations in the
relational model. Example: In this example, we have an Employee table.
● Tuples: Each row in the table is called tuple. A row contains all the information about
any instance of the object. In the above example, each row has all the information about
any specific individual like the first row has information about John.
● Attribute or field: Attributes are the property which defines the table or relation. The
values of the attribute should be from the same domain. In the above example, we have
different attributes of the employee like Salary, Mobile_no, etc.
● Simple: This model is more simple as compared to the network and hierarchical model.
● Scalable: This model can be easily scaled as we can add as many rows and columns we
want.
● Structural Indepe ndence: We can make changes in database structure without changing
the way to access the data. When we can make changes to the database structure without
affecting the capability to DBMS to access the data we can say that structural
independence has been achieved.
● Hardware Overheads: For hiding the complexities and making things easier for the user
this model requires more powerful hardware computers and data storage devices.
● Bad Design: As the relational model is very easy to design and use. So the users don't
need to know how the data is stored in order to access it. This ease of design can lead to
the development of a poor database which would slow down if the database grows.
But all these disadvantages are minor as compared to the advantages of the relational model.
These problems can be avoided with the help of proper implementation and organisation.
Object-Relational Model
As the name suggests it is a combination of both the relational model and the object-oriented
model. This model was built to fill the gap between object-oriented model and the relational
model. We can have many advanced features like we can make complex data types according to
our requirements using the existing data types. The problem with this model is that this can get
complex and difficult to handle. So, proper understanding of this model is required.
It is a simple model in which the database is represented as a table consisting of rows and
columns. To access any data, the computer has to read the entire table. This makes the modes
slow and inefficient.
Semi-Structured Model
Associative Data Model is a model in which the data is divided into two parts. Everything which
has independent existence is called as an entity and the relationship among these entities are
called association. The data divided into two parts are called items and links.
● Item: Items contain the name and the identifier (some numeric value).
● Links: Links contain the identifier, source, verb and subject.
Example : Let us say we have a statement "The world cup is being hosted by London from 30
May 2020". In this data two links need to be stored:
1. The world cup is being hosted by London. The source here is 'the world cup', the verb 'is
being' and the target is 'London'.
2. ...from 30 May 2020. The source here is the previous link, the verb is 'from' and the target
is '30 May 2020'.
DATABASE SYSTEM
PURPOSE:
The diagram given below explains the process as to how the transformation of data to
information to knowledge to action happens respectively in the DBMS –
Types of DBMS:
● Network DBMS - this type of DBMS supports many-to- many relations. This usually
results in complex database structures. RDM Server is an example of a database
management system that implements the network model.
● Relational DBMS - this type of DBMS defines database relationships in the form of
tables, also known as relations. Unlike network DBMS, RDBMS does not support many
to many relationships. Relational DBMS usually have pre-defined data types that they
can support. This is the most popular DBMS type in the market. Examples of relational
database management systems include MySQL, Oracle, and Microsoft SQL Server
database.
● Object-Oriented DBMS - this type supports the storage of new data types. The data to
be stored is in the form of objects. The objects to be stored in the database have attributes
(i.e. gender, ager) and methods that define what to do with the data. PostgreSQL is an
example of an object-oriented relational DBMS.
DATABASE LANGUAGES
A DBMS has appropriate languages and interfaces to express database queries and updates.
Database languages can be used to read, store and update the data in the database.
Once data is stored or filled it requires manipulation like insertion, deletion, updating, and
modification of data. For these operations a set of languages are provided by the database
management system (DBMS). So, the database languages are used to read, update and store data
in the database.
o DDL stands for Data Definition Language. It is used to define database structure or
pattern.
o It is used to create schema, tables, indexes, constraints, etc. in the database.
o Using the DDL statements, you can create the skeleton of the database.
o Data definition language is used to store the information of metadata like the number of
tables and schemas, their names, indexes, columns in each table, constraints, etc.
These commands are used to update the database schema that's why they come under Data
definition language.
DML stands for Data Manipulation Language. It is used for accessing and manipulating data in
a database. It handles user requests.
o DCL stands for Data Control Language. It is used to retrieve the stored or saved data.
o The DCL execution is transactional. It also has rollback parameters.
(But in Oracle database, the execution of data control language does not have the feature
of rolling back.)
There are the following operations which have the authorization of Revoke:
TCL is used to run the changes made by the DML statement. TCL can be grouped into a logical
transaction.
o The basic client/server architecture is used to deal with a large number of PCs, web
servers, database servers and other components that are connected with networks.
o The client/server architecture consists of many PCs and a workstation which are
connected via the network.
o DBMS architecture depends upon how users are connected to the database to get their
request done.
1-Tier Architecture
2-Tier Architecture
3-Tier Architecture
Database architecture can be seen as a single tier or multi- tier. But logically, database
architecture is of two types like: 2-tier architecture and 3-tier architecture.
1-Tier Architecture
o 1 Tier Architecture in DBMS is the simplest architecture of Database in which the client,
server, and Database all reside on the same machine.
o In this architecture, the database is directly available to the user. It means the user can
directly sit on the DBMS and uses it.
o Any changes done here will directly be done on the database itself. It doesn't provide a
handy tool for end users.
o 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
o A 2 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.
o 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.
o The 2-Tier architecture is same as basic client-server. In the two-tier architecture,
applications on the client end can directly communicate with the database at the server
side. For this interaction, API's like: ODBC, JDBC are used.
o The user interfaces and application programs are run on the client-side.
o The server side is responsible to provide the functionalities like: query processing and
transaction management.
3-Tier Architecture
o A 3 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.
o The 3-Tier architecture contains another layer between the client and server. In this
architecture, client can't directly communicate with the server.
o The application on the client-end interacts with an application server which further
communicates with the database system.
o 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.
● Telecom: There is a database to keeps track of the information regarding calls made,
network usage, customer details etc. Without the database systems it is hard to maintain
that huge amount of data that keeps updating every millisecond.
● Industry: Where it is a manufacturing unit, warehouse or distribution centre, each one
needs a database to keep the records of ins and outs. For example distribution centre
should keep a track of the product units that supplied into the centre as well as the
products that got delivered out from the distribution centre on each day; this is where
DBMS comes into picture.
● Banking System: For storing customer info, tracking day to day credit and debit
transactions, generating bank statements etc. All this work has been done with the help of
Database management systems.
● Sales: To store customer information, production information and invoice details.
● Airlines: To travel though airlines, we make early reservations, this reservation
information along with flight schedule is stored in database.
● Education sector: Database systems are frequently used in schools and colleges to store
and retrieve the data regarding student details, staff details, course details, exam details,
payroll data, attendance details, fees details etc. There is a hell lot amount of inter-related
data that needs to be stored and retrieved in an efficient manner.
● Online shopping: You must be aware of the online shopping websites such as Amazon,
Flipkart etc. These sites store the product information, your addresses and preferences,
credit details and provide you the relevant list of products based on your query. All this
involves a Database management system.
● Finance : For storing information about stock, sales, and purchases of financial
instruments like stocks and bonds.
● HR Management: For information about employees, salaries, payroll, deduction,
generation of paychecks, etc.
● Manufacturing: It is used for the management of supply chain and for tracking
production of items. Inventories status in warehouses.
● Social Media Websites: By filling the required details we are able to access social media
platforms. Many users daily sign up for social websites such as Facebook, Pinterest and
Instagram. All the information related to the users are stored and maintained with the
help of DBMS.