You are on page 1of 64

Fundamentals of Database

Management System: CsEg2061


By Diriba A. (MSc.)
BHU, 2023/2016
1.2: DB System Concept and Architecture
Data Model:
 The modeling of the description of data along with the data

semantics and consistency constraints on the data.

 It offers the conceptual tools to describe the structure of a

database at every degree of data abstraction.

2
Cont.
I. High-Level Conceptual Data Model:

 provide concepts for presenting data in ways that are close to the way

people perceive data.

 Defines What the system contains.

 Created by Business stakeholders and Data Architects.

 Purpose is to organize, scope and define business concepts and rules.

3
Cont.
a. Entity-Relation Ship: uses main concepts like entities, attributes and
relationships.
 An entity represents a real-world object such as an employee or a

project.
 The entity has attributes that represent properties such as an

employee’s name, address and birthdate.


 A relationship represents an association among entities; for example,

an employee works on many projects.

4
Cont.
 Entity-Relation Ship Data Model represent the structure of

database in pictorial form which is known as ER-diagram.

 Entity: Employee, Company


 Relationship: Works in
 Attributes:
 Employee  Emp.Id, Name, DoJ
 Compony  Reg.No, Name

5
Cont.
Features of Entity-Relation Ship Data Model:

 Graphical Representation for Better Understanding: It is very easy

and simple to understand, so it can be used by the developers to


communicate with the stakeholders.

• ER Diagram: ER diagram is used as a visual tool for representing the

model.

• Database Design: helps the database designers to build the database

and is widely used in database design.

6
Cont.
Advantages of Entity-Relation Ship Data Model:

• Simple: Conceptually ER Model is very easy to build. If we know

the relationship between the attributes and the entities we can easily
build the ER Diagram for the model.

• Effective Communication Tool : used widely by the database

designers for communicating their ideas.

• Easy Conversion to any Model : maps well to the relational model

and can be easily converted relational model by converting the ER


model to the table and can also be converted to any other model
like network model, hierarchical model etc.
7
Cont.
Disadvantages of Entity-Relation Ship Data Model:

• No industry standard for notation: There is no industry standard for

developing an ER model. So one developer might use notations which


are not understood by other developers.

• Hidden information: Some information might be lost or hidden in the

ER model. As it is a high-level view, so there are chances that some


details of information might be hidden.

8
Cont.
II. Record-Based Logical Data Model:

 provide concepts users can understand but are not too far from the way

data is stored in the computer.

 provide concepts for presenting data in ways that are close to the way

people perceive data.

 Defines How the system is implemented.

 Created by Business Analysts and Data Architects.

 Purpose is to develop technical map of rules and data structures.

9
Cont.
a. Relational Data Model: represents data as relations, or tables.
The most widely used.

All information stored in rows and columns.

10
Cont.
Features Relational Data Model:
 Tuples: rows which contains all the information about any instance of the

object.

 Attribute/Field: Column, property which defines the table or relation.

Advantages of Relational Data Model:


 Simple: compared to Network and Hierarchical.

 Scalable: ease of column and row adding.

 Structural Independence: make changes in database structure without


changing the way to access the data (without affecting the capability to
DBMS to access the data).

11
Cont.
Disadvantages of Relational Data Model:

• 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: 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.

12
Cont.
Compared to its advantages, disadvantages of relational model
are minor and can be avoided with the help of proper
implementation and organization.

b. Network Data Model: represents data as record types and


limited type of one to many relationship called a set type.

 Expansion of Hierarchal DM.

 the most popular model before the relational model.

13
Cont.
Network Data Model is similar to Hierarchical DM in but, record
can have more than one parent, replaces the hierarchical tree with a
graph.

Node: Student
Parents: CSE Dept, Library

NB: This was earlier not possible


in Hierarchical DM.

14
Cont.
Features of Network Data Model:

 Ability to Merge more Relationships: 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.

 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.

 Circular Linked List: The operations on the network model are done 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.

15
Cont.
Advantages of Network Data Model:

 Data can be accessed faster as compared to the hierarchical model

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 there is a parent-child relationship so data integrity is present,

any change in parent record is reflected in the child record.

16
Cont.
Disadvantages of Network Data Model:

 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.

 Any change like updating, deletion, insertion is very complex.

17
Cont.
c. Hierarchical Data Model: represents data as a hierarchical tree
structure in which each branch of the hierarchy represents a number of
related records.
 The first model.

 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.

18
Cont.
e.g. r/ship between shoes present on shopping website:

19
Cont.
Features of Hierarchical Data Model:

 One-to-many relationship: only one path from parent to any node.

 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.

 Deletion Problem: If a parent node is deleted then the child node is

automatically deleted.

 Pointers: Pointers are used to link the parent node with the child node and are

used to navigate between the stored data.

20
Cont.
Advantages of Hierarchical Data Model:

 Very simple and fast to traverse through a tree-like structure.

 Any change in the parent node is automatically reflected in the child node so,

the integrity of data is maintained.

Disadvantages of Hierarchical Data Model:

• Complex relationships are not supported.

• As it does not support more than one parent of the child node, if we have some

complex relationship where a child node needs to have two parent node, then
that can't be represented.

• If a parent node is deleted, child node is automatically deleted.

21
Cont.
Object-Oriented Data Model:

 represents data as objects, which are instances of classes.

 both the data and relationship are present in a single structure known as an

object.

 each object has a unique identity, a set of properties (or attributes), and a set of

methods (or behaviors) as well as classes which are templates that define the
properties and methods of the objects, and objects are instances of those classes
with specific values for those properties.

22
Cont.

Objects: student, Department


Attributes: Name, Dept_no, etc.
Methods: getMarks, getInfo 23
Cont.
Object-Oriented Data Model Advantage:

• Due to inheritance, the data types can be reused in different objects.

This reduces the cost of maintaining the same data in multiple locations.
• Quite flexible in most cases.

• It is easier to extend the design.

Object-Oriented Data Model Disadvantage:

 It is not practically implemented in database systems as it is mostly a

theoretical approach.

 Quite complicated to create and understand.

24
1.2: Schema and Instances
 Schema: defines how data is organized within a relational
database; logical constraints such as, table names, fields, data
types, and the relationships between these entities.

25
Cont.
 Logical Schema – the overall logical structure of the database

 Example: The database consists of information about a set of

customers and accounts in a bank and the relationship between them


Analogous to type information of a variable in a program

 Physical schema– the overall physical structure of the database

26
Cont.
 Instance – the actual content of the database at a particular point in time

 Analogous to the value of a variable

 Physical Data Independence – the ability to modify the physical

schema without changing the logical schema


 Applications depend on the logical schema

 In general, the interfaces between the various levels and components

should be well defined so that changes in some parts do not seriously


influence others.

27
Three-Schema Architecture
 ANSI/SPRC or Three-level architecture.

 describes how the data is represented or viewed by the user in the db.

 divides the database into three-level to create a separation between

the physical database and the user application.

 hides the details of physical storage from the user.

 Database administrator (DBA) should be able to change the structure of

database storage without affecting the user’s view.

28
Cont.
3 layers/ Levels dbms architectures:
1. External level (front end developer, user level)
2. Conceptual level (database designer, logical level)
3. Internal level (administrator, physical level)

29
Cont.
1. External level:
 This is the highest level of database abstraction.
 External or view level tells the actual view of data that is relevant to the
particular user.
 View/external level provides different views of the same DB for a specific user
or a group of users. E.g. view for faculty student is different than faculty
admin.
 develops with the help of front end programming (Javascript, HTML etc)
 external view provides a powerful and flexible security by hiding some
information of the database from a particular user.

30
Cont.
2. Conceptual/Logical Level:
 Tells the structure of the entire database.
 Act as a intermediate layer between the physical storage(DB) and external
level.
 Database designer works on this layer which provides the structure of database.
 Any database model (i.e. Relational or ER Model) can use at this level which
provides the structure of database.

Nb: data can be stored in the form of file, but it view in the form of table.
31
Cont.
3. Internal/Physical Level:
 The lowest level of database abstraction.
 Database administrator works on this layer where it has complete control over
data
 Describes how the physical data is actually stored (in the form of file) in the
database and provides methods to access data from the database.
 It shows the physical representation of the database as it exists actual on the
computer system.
 Changes in physical database storage devices (i.e. hard disks) and the files
organization on database storage devices, are hidden to application programs
and users.

32
Database Languages and Interfaces
 also known as query languages or data query languages, are a
classification of programming languages that developers use to define
and access databases, which are collections of organized data that users
can access electronically.
 allow users to complete tasks such as controlling access to data,
defining and updating data and searching for information within the
database management system (DBMS).

33
4 Categories of Database Languages

34
Cont.
I. DDL (Data Definition Language):
 used for defining the structure or schema of the database. It is also
used for creating tables, indexes, applying constraints, etc. in the
database.
The main purpose of DDL is to store the information of metadata like
the number of schemas and tables, their names, indexes, constraints,
columns in each table, etc.
 Result: a set of tables which are stored in a special file called data
directory or data dictionary.

35
Cont.
DDL Commands:
 Create: to create a new table or a new database.
 Alter: to alter or change the structure of the database table.
 Drop: to delete a table, index, or views
 Truncate: to delete the records or data from the table, but its structure
remains as it is.
 Rename: to rename an object from the database.
 Comment: used for adding comments to our table.

36
Cont.
II. DML (Data Manipulation Language):
 language used to access or manipulate (insert, retrieve, and delete the
existing data from the database).
2Types:
1. Procedural (Low-level) : describes what data is to be accessed and
how to get that data.
 user needs to define “what data is needed and how to get that” e.g.
relational algebra.
2. Declarative DML or Non-procedural (High-level): only describes
what data is to be accessed without specifying how to get it.
 user needs to define just “what is needed”, Its not required to define
any procedure to get that data. E
e.g. SQL : compiler generates procedures.

37
Cont.
DDM Commands:
 Select: to retrieve or access the data from the database table.
 Insert: to insert the records into the table.
 Update: to change/update the existing data in a table.
 Delete: to delete one or all the existing records from the table.

38
Cont.
III. DCL (Data Control Language):
 used to access the stored or saved data and mainly used for revoking
and granting user access on a database.
 In the Oracle database, this language does not have the feature of
rollback.
 It is a part of SQL.

39
Cont.
DCL Commands:
 Grant: allows user’s access privileges to the database.
 Revoke: removes the accessibility of users from the database objects.

40
Cont.
IV. TCL (Transaction Control Language):
 language which manages transactions within the database and used to
execute the changes made by the data DML statements.
TCL Commands:
 Commit: This command is used to save the transactions in the
database.
 Rollback: This command is used to restore the database to that state
which was last committed.

41
DBMS Architecture
 outline of the structure of a specific database system, as well as how
users are connected to that particular database system.
 Depending on its architecture, a DBMS may be centralized (all the
data resides at one location), decentralized (multiple copies exist at
various locations), or hierarchical.

42
Why DBMS Architecture
 Databases are not always directly accessible by users or applications to
store or access data, so we must use various architectures to maintain
them based on how users are connected to the database.
 DBMS architectures vary according to how users (clients) connect to
the database servers to carry out their requests and can be categorized
as single-tier, two-tier, or multi-tier.

43
Most Popular DBMS Architectures
I. Single-Tier:
 Called local db system
 the simplest DBMS architecture, in which the client, server, and
database are all on the same machine. This architecture
 Puts the user directly in contact with the database itself, so the user can
create, modify, or delete data within the database.
 user sits directly on the database, without any intermediary layer.

44
Cont.

45
Cont.

 SQL server and Database were on local machine in order to


understand the Structure Query Language (SQL).
 With the help of this SQL server, we are able to do some operations
and interact with the relational Database without the need for a
network connection.
46
Cont.
 Changes can be made easily by the user without the need to use a
special tool. Every change made by the client is immediately reflected
in the database, and all processing is carried out on one server.
Pros: perform the operation directly on the database and get a quick
response, Zero network for operating db.
Cons: no real security in this architecture, only recommended when
creating a local application, used if db is not changing rapidly and multi-
user is not accessing, any update/modification can directly affect the db.

47
Cont.
ii. Two-Tier:
 similar to that of a client-server architecture.
 Client-side applications establish a connection with the server side to
communicate with the database.
 This interaction is performed through APIs (Application
Programming Interfaces) such as JDBC (Java Database Connectivity)
or ODBC (Open Database Connectivity). User interfaces and
application programs are executed on the client side.

48
Cont.
 Query processing and transaction management are handled on the
server side.
 Client-side applications can access the database server directly via
API calls, which enables the application to remain independent of the
database with respect to design, programming, and operation.
 It is more secure to have a two-tier architecture, as DBMS is not
exposed directly to end-users.

49
Cont.

NB: client is typically the one who requests services, in this case, access
to the database data, whereas the server responds to the client’s request
by providing the needed service.

50
Cont.
 Query processing and transaction management are handled on the
server side.
 Client-side applications can access the database server directly via
API calls, which enables the application to remain independent of the
database with respect to design, programming, and operation.
 It is more secure to have a two-tier architecture, as DBMS is not
exposed directly to end-users.

51
Cont.

Imagine you go to a restaurants outlet. You go to the counter to order a


fresh Pizza. The person on the counter take your order and give you your
receipt.

52
Cont.
In 2-tier architecture, Client Layer holds the application and
communicates with the database. In our case, it is the counter person. The
user has no communication with the database.
Pros: perform Limited users, only authorized person to communicate with
the database, low Maintenance.
Cons: Low Scalability and security(machine is interacting directly with
the database).

53
Cont.
iii. Three-Tier:
 one of the most frequently used dbms architecture.
 Between the server (Database layer) and client (Presentation layer), an
additional layer known as the Application layer is added to reduce the
server’s query processing burden.
 The modular architecture allows the independent development and
maintenance of functions, logic, data access, data storage, and user
interfaces.
 Separate the tiers based on users’ complexity and how they interact
with the data available in the database.

54
Cont.

55
Cont.

 User interact with db server through app, but no idea about db server
and client.

56
Cont.

57
Cont.
To create a sales report based on the sales data stored:
i. Presentation layers send API calls to the data layer
ii. Data layer of the fine report runs the query and returns the results to the
application layer, which formats it into a web page.
iii. The page is then sent back to the browser, where the presentation layer
displays the reports on a laptop or other device.
 In three-tier, client and server are not directly connected; therefore, all requests
from users are handled by the Application Layer, i.e. the requests are validated
and verified by the Intermediate Layer before being forwarded to the server.

58
Cont.
 By eliminating direct client-server communication, the server is less
burdened with query processing, and overall DBMS security is
enhanced as the client cannot communicate directly with the server.
 A three-tier DBMS architecture is therefore composed of an
application layer that ensures load balancing, query request accuracy,
and security.
 Usually, this type of architecture is used in cases where large web
applications must handle a great deal of traffic

59
Cont.
3-tier architecture Pros:
 Maintaining data integrity: application layer performs checks on each
client’s request to prevent data corruption and wrong user requests.
 More secure: client can’t interact directly with the server, thereby
preventing unauthorized access to data.
 A database server is not aware of any users beyond the application
layer, and the application layer performs load balancing, so you can
have multiple clients.

60
Cont.
3-tier architecture Cons:
 difficult for developers to make updates to an application with the
agility and flexibility necessary to keep up with the needs of mobile
users as well as for operations teams to scale the service up or down to
meet demand.
 strong understanding of the object−oriented concept is required.
 Complex than 2-tier and network traffic may exist if separate proxy
server is used.

61
Database System Environments
 Collective system of components that comprise and regulates the
group of data, management, and use of data, which consist of
software, hardware, people, techniques of handling database, and the
data also.

62
Cont.
I. HW: physical devices (storage devices, processors, input and output
devices, printers, network device)
e.g. computer, printer, etc.
II. SW: all SW to access, store and regulate the database.
e.g. OS, DBMSW, Application and Utility Programs.
 OS: invokes computer hardware, and let other software runs.
 DBMSW: controls and regulates the database.
 App and Utility Programs: access and manipulate the database.

63
Cont.
III. People: admin (monitoring), analyst(make sense info),
programmer(interface designer), end-user (access), designer, etc.
IV. Procedure: function that regulates and controls the use of the
database.
V. Data : known fact that can be recorded and it has an implicit meaning

64

You might also like