Databasemanagementsystem 221106165504 00f6ec2c

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

DATABASE MANAGEMENT SYSTEM

INTRODUCTION TO DATABASES

A database is a collection of data organized to serve many


application. By using centralized data it can easily be accessed,
managed, and updated.
And a DATABASE MANAGEMENT SYSTEM (DBMS) is a collection
of programs that enables you to store, modify, and extract
information from a database.
ADVANTAGES OF USING A DATABASE APPROACH
• Flexible Data Access.
• Improved Data Integrity (purity,).
• Improved Data Security.
• Data Independence.
• Reduced Data Redundancy (excess).
• Ability to Share and Relate Data
• Standardisation of Data.
• Increased Productivity.
DBMS and Its Applications:
A DATABASE MANAGEMENT SYSTEM (DBMS) is a
computerized record-keeping system. It is a repository or a
container for collection of computerized data files.
Application are as follows:
– Banking
– Airlines
– Universities
– Manufacturing and selling
– Human resources
– Railway reservation system
– Library management system
– Social media sites
– Telecommunications
– Online shopping
– Human resource management
ELEMENT OF DATABASE

FIELDS: A field is part of a record and contains a


single piece of data for the subject of the record.
In the database table illustrated in Figure 4, each
record contains four fields:
RECORDS: Data is stored in records. A record is
composed of fields and contains all the data
about one particular person, company, or item
in a database. In this database, a record contains
the data for one customer support incident
report. Records appear as rows in the database
table. A record for Log ID 1201242 is highlighted
in Below mentioned Figure.
TABLES: A database table is composed of
records and fields that hold data. Tables are also
called datasheets. Each table in a database holds
data about a different, but related, subject.
An Example of a Table

Fields

Records
Name GatorLink Phone College
Graff rgraff 392-3900 Pharmacy
Harris bharris 392-5555 Medicine
Ipswich zipswich 846-5656 PHHP
KEY FIELD: A field of a database (typically a
relational database ) table which together form
a unique identifier for a record (a table entry).
The aggregate of these fields is usually referred
to simply as "the key ".
PRIMARY KEY

• The column or set of columns that provide the


uniqueness for the row.
• A table can have only one primary key.
• Existing values in primary key columns may not be
modified (insert new value and then delete old
value)
• The table of a relationship containing the primary key
is called the Parent Table.
FOREIGN KEYS
• A primary key referenced from another table is
called a foreign key
• For each foreign key value, there must be a row in
a table whose primary key has the same value.
• The foreign key can be made up of one or more
columns of a table but must match the primary
key it is referencing
• A table can have any number of foreign keys.
PRIMARY KEYS & FOREIGN KEYS
Name User Phone College
Graff rgraff 392-3900 Pharmacy
Harris bharris 392-5555 Medicine
Ipswich zipswich 846-5656 PHHP

To ensure that each record is unique in each


table, we can set one field to be a Primary Key
field.
A Primary Key is a field that that will contain
no duplicates and no blank values.
Foreign Keys link to data in other tables
DATA MODELS
1. HIERARCHICAL
2. NETWORK
3. RELATIONAL
4. OBJECT
1. HIERARCHICAL MODEL
Stores data as hierarchically related to each
other. Record shape are tree structure.
BUET

Faculty of Faculty of
Civil Engineering Architectural

CE WRE URP Archit.


HIERARCHICAL DATABASE MODEL
HIERARCHICAL DATABASE MODEL
• Logically represented by an upside down
tree
– Each parent can have many children
– Each child has only one parent
HIERARCHICAL MODEL
• Several records or files are hierarchically related with each
other. For example, an organization has several departments,
each of which has attributes such as name of director, number
of staffs, annual products etc.

• Each department has several divisions with attributes of name


of manager, number of staffs, annual products etc.

• Then each division has several sections with attributes such as


name of head, number of staff, number of PCs etc.
Advantage and Disadvantages of
Hierarchical Model
 Advantages
 High speed access to large databases
 Easy to update- (to add or delete new nodes)

 Disadvantages
 Links are only possible in Vertical Direction (from top to
bottom) but not for horizontal or diagonal unless they
have same parents.
 For example, it is hard to find what is the relation
between URP and DCE from this data model.
2. NETWORK DATABASE MODEL
• Doesn’t force data into hierarchical levels
• Owner/Member relationships:
– Owner record type
– Member record type
• Each owner may have one or more member types
• Each member type and corresponding owner record
type form set, which represents relationship
Network Database Model
Network Database Model
• Each record can have multiple parents
– Composed of sets - relationships
– Each set has owner record and member record
– Member may have several owners
– A set represents a 1:M relationship between the
owner and the member

Figure 1.10
3. RELATIONAL MODEL
Student Table
Student Name CourseID
• Based on two important ID
concepts:
1 Mr. X 001

– Key of relation - one to 2 Mr. X 002


one, one to many, many to 3 Mr. Y 003
many
Course table

– Primary attribute – which Cour Title Cre


can’t be duplicate seID dit

001 RS & GIS in WM 3

* 002 Watershed Hydrology 3


*
Student Table Course Table
003 Risk Management 3
Many to many relationship
WHAT IS A RELATIONAL DATABASE?
• A database is more than just a collection of
information. Such as student and course information,
faculty and grades.
• A database is a representation of the people and
things your business needs to operate, and the way
those people and things relate to each other.
• A database system supports the business rules
defined by the customer.
RELATIONSHIP TYPES
1. One-to-One : relationship is single valued in both directions. A
manager manages one department; a department has only
one manager.
2. One-to-Many : relationship is multi-valued in one direction -
one row in the parent table is associated with many rows in
the dependent table. One department has many employees.
3. Many-to-Many : relationships are multi-valued in both
directions. This type of relationship can be expressed in a
table with a column for each entity. (crosswalk table) - An
employee can work on more than one project, and a project
can have more than one employee assigned. Employee,
Project, and Employee/Project tables.
Relational Database Model
Relational Database Model

Figure 1.11
WHAT IS QUERY LANGUAGE?
• Query language (QL) refers to any computer
programming language that requests and
retrieves data from database and information
systems by sending queries.
WHAT IS QUERY ?
A query is a request for information from a
database.
SQL

What is it?
Structured Query Language
• Used in ORACLE and other DB systems
• Non-procedural - i.e. Specify what you want not how
to get it
• SQL - (also pronounced SEQUEL)
directly related to the development of the
RELATIONAL MODEL by E.F.Codd.
SQL
• SQL is used to perform query in relations databases.

• For example, find the name of the student who took


more than or equal to 6 credit hour in this term

SELECT Student.Name, Course.Credit


FROM Student, Course
WHERE Student.CourseID = Course.CourseID
AND Credit >= 6

• The answer is :
Mr. X 6
Find the relationship between this two
tables in the BUET Library
Book Table

ISBN Title Author


050 Applied David
Hydrology Maidmen
060 Irrigation Cheng One to one
Many to Many
Borrow Table One to Many
ID Name ISBN
?
1 Mr. P 050
2 Mr. Q 060
3 Mr. R 070
Advantage of Relational Database
 Advantages
 there is no redundancy.
 type of building of an owner can be changed without destroying the
relation between type and rate.
 a new type of building for example "Clay" can be inserted. (row insert
is easy).

 Disadvantages
 Require a number of tables and relationship
 Its difficult to add a new column in the table.
4. OBJECT DATABASES
• Current generation systems have a need to handle complex
data for complex applications such as
– computer aided design
– computer aided software engineering
– geographic information systems
– interactive web sites

• Relational systems are inadequate for these systems


– Why do you think this is?
Object Database Types
• Object-oriented
– extend a programming language such as Java with
persistency and a query language
• Object-relational
– extend a current RDBMS (e.g. Oracle) with object-
oriented extensions
Object Oriented Model

BUET

Part of
Part of

Departments Institutes

Is a Is a Is a

CE URP DCE IWFM AIT


WRE

Is a = Inheritance
Attributes: Faculty, Staff, Students
Part of = association
OBJECT ORIENTED DATABASE
• An Object Oriented model uses functions to model spatial and non-
spatial relationships of geographic objects and the attributes.

• An object is an encapsulated unit which is characterized by attributes,


a set of orientations and rules. An object oriented model has the
following characteristics.

• GENERIC PROPERTIES : there should be an inheritance relationship.


• ABSTRACTION : objects, classes and super classes are to be generated
by classification, generalization, association and aggregation.
• ADHOC QUERIES : users can order spatial operations to obtain spatial
relationships of geographic objects using a special language.

You might also like