0% found this document useful (0 votes)
19 views41 pages

Advanced Database Management System

Uploaded by

misrak dagne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views41 pages

Advanced Database Management System

Uploaded by

misrak dagne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

Advanced Database System

Revisions of Fundamentals of
Database System
What is Database?
• Database is defined as an organized collection of
logically related data
• Database is a collection of data arranged for ease
and speed of search and retrieval
• Database is a collection of data about multiple
entities and R/ship b/n them
• Database is a backbone of any system
Database is collection of tables
Example of a Table
Fields

Records Name GatorLink Phone College


Smith rsmith 392-3900 Pharmacy
Thomas bthomas 392-5555 Medicine
Van Winkle sleepyguy 846-5656 PHHP
Database Applications
 Banking: transactions

 Airlines: reservations, schedules

 Universities: registration, grades

 Sales: customers, products, purchases

 Online retailers: order tracking, customized recommendations

 Manufacturing: production, inventory, orders, supply chain

 Human resources: employee records, salaries, tax deductions

 Medical Databases can be very large.

 Databases touch all aspects of our lives


Database Management System
 A software system that is used to create, maintain, and
provide controlled access to user databases

Order Filing
System

Invoicing Central database


DBMS
System
Contains employee,
order, inventory,
pricing, and
Payroll
customer data
System

DBMS manages data resources like an operating system manages


hardware resources
Advantage of Using the DBMS

1) Controlling redundancy
2) Restricting unauthorized Access
3) Better service to the Users
4) Enforcing Integrity Constraint
5) Enforces standard
6) Cost of developing and maintaining systems is
lower
7) Flexibility of the system is improved
8) Provide backup and recovery
Actors on the Database Environment
1) Database Administrator
2) Database Designer
3) End users
Database Administrator
• The database administrator is responsible for authorizing
access to the database, for coordinating and monitoring its
use and for acquiring software and hardware resources as
needed.
• The DBA is accountable for problem such as breach of
security or poor system response time. In large
organizations
What is Entities

• Entities is a "thing" in the real world with an


independent existence.
• An entity may be an object with a physical existence—
 a particular person
 car
 house
 or employee Instructor
 Student
— or it may be an object with a conceptual existence

– a company , a job or a hospital. More concisely
Entities CONT…
• an entity is defined as any object in the system that we
want to model and store information about.
What is Attributes ?
• An Attribute is a property that describes an entity. For
example, the student is the entity and
• sid, name,
• address, and sex are attributes of Student.
• A specific entity will have a value for each of its
attributes. For example a specific student entity
• may have Name='Abera Hailu', sid='5846', Sex ='M',
Age = 25‘, Address= ' Addis Ababa’.
• An attribute can be classified in four
1. Simple (KEY) attribute
2. Composite attribute
3. multi-valued attribute.
4. Derived attribute.

.
Domain
• Each attribute has a domain, an expression of the
allowable values for that attribute.
• A common method of specifying a domain is to
specify a data type from which the data values
forming the domain are drawn Some examples of
domains are shown below:
• Office phone: The set of 10-digit valid phone
numbers in Ethiopia
• Age: is between 0 and 125.
• Sex: Male or Female
• .
• Relationships
• A relationship relates two or more distinct entities with a
specific meaning.
• Types of relationships
A) One-to-one relationships
B) One-to-many or many-to-one relationships
C) Many-to-many relationships
Relational keys
• There are many types of keys that can be defined in
the relational model. These have significant
importance in maintaining data consistency and
correctness in the database.
1. Candidate Key
2. Primary Key
3. Foreign Key
Candidate Key
• A candidate key is one or more attribute that uniquely
identifies an entity. Every entity in relational database
must have at least one candidate key but it is possible
that some may have two or more.
• For example, sid and sname of the student may
identify the student. Therefore sid and sname can
be considered candidate keys for a student table.
 Primary Key
• A primary key is an attribute, or set of attributes,
that allows each information for an entity to be
uniquely identified. Every entity in a relational
database must have a primary
Foreign Key

• Entities are related to each other through foreign


keys. A foreign key references a particular attribute of
an entity containing the corresponding primary key.
• For example, a Student entity with sid as its primary
key for a Student and Instructor entity with Instructor
Id as its primary key for Instructor information can be
related to each other through sid.
• Therefore, sid will be a foreign key for Instructor
entity where as the MRN will be a primary key for the
Student entity.
TYPES OF CONSTRAINTS
• There are Six types of constraints can be
placed when creating a table:
1. NOT NULL Constraint Ensures that a column
cannot have NULL value.
Example:
For example, the following SQL creates a new
table called CUSTOMERS and adds five columns,
three of which, ID and NAME and AGE, specify
not to accept NULLs
16
2. DEFAULT Constraint :
Provides a default value for a column when none is
specified.
If CUSTOMERS table has already been created, then
to add a DFAULT c constraint to SALARY column,
you would
write a statement similar to the following:
ALTER TABLE CUSTOMERS
MODIFY SALARY DECIMAL (18, 2) DEFAULT 5000.00;
To drop a DEFAULT constraint, use the following SQL:
ALTER TABLE CUSTOMERS
ALTER COLUMN SALARY DROP DEFAULT;
3. UNIQUE Constraint:
Ensures that all values in a column are
different.
The UNIQUE Constraint prevents two
records from having identical values in a
particular column. In the
CUSTOMERS table, for example, you might want
to prevent two or more people from having
identical age
4. CHECK Constraint:
• The CHECK Constraint enables a condition
to check the value being entered into a
record.
• If the condition evaluates to false, the record
violates the constraint and isn’t entered into
the table.
• Makes sure that all values in a column satisfy
certain criteria
• For example, the following SQL creates a new
table called CUSTOMERS and adds five columns.
Here,
• we add a CHECK with AGE column, so that you
can not have any CUSTOMER below 18 years
5· Primary Key Constraint:
• A primary key is a field in a table which
uniquely identifies each row/record in a
database table.
• Primary keys must contain unique values.
• A primary key column cannot have NULL
values.
• A table can have only one primary key

22
6· Foreign Key Constraint:
 A foreign key is a key used to link two tables together.
 A foreign key is sometimes called a referencing key.
 Foreign Key is a column or a combination of columns
whose values match a Primary Key in a different table.
 The relationship between 2 tables matches the Primary
Key in one of the tables with a Foreign Key in the second
table.
Learning Objectives

• At the end of this topic the student should be able to


 Know Object Identity
 Identify Applications of OODBS
 Know Object Structure
 Identify Type Constructors
 define Encapsulation of Operations, Methods, and
Persistence
 Know Type of Hierarchies and Inheritance
Introduction
What is object-oriented database ?
• An object database is a database management system
in which information is represented in the form of
objects as used in object-oriented programming.
• Object databases are different from relational
databases, which are table-oriented. Object-relational
databases are a hybrid of both approaches.
Advantages of OODBS
• Designer can specify the structure of objects and their
behavior (methods)
• Better interaction with object-oriented languages such as
Java and C++
• Definition of complex and user-defined types
• Encapsulation of operations and user-defined methods
Applications for OO databases
• There are many fields where it is believed that the OO
model can be used to overcome some of the
limitations of Relational technology,
where the use of complex data types and the need for
high performance are essential.
These applications include:
Computer-aided design and manufacturing (CAD/CAM)
Computer-integrated manufacturing (CIM)
Computer-aided software engineering (CASE)
Geographic information systems (GIS)
Many applications in science and medicine
Document storage and retrieval
What is the identity of an object?

• Object identity is a fundamental object orientation


concept. With object identity, objects can contain or
refer to other objects.
• Identity is a property of an object that distinguishes the
object from all other objects in the application.
• Any object has 2 component(properties) i.e.
1 state (value)
2 behavior(operations).
hence, it’s similar to the program variable but object
has complex structure.
Types of Object
• There are two types of object :-
1.) Transient object
2.) Persistent object
• 1.) Transient object: - These objects exist during the
execution but destroy ones the program terminates.
• 2.) Persistent object: - These objects persist & store
into database even if program terminate.
• Whenever any object created DBMS assigns unique
identifier called as object identity & its abbreviated as
OID.
USES OF OBJECT IDENTITY(OID)

• OID is used for two purposes.


1. To identity each objects uniquely.
2. Make reference to another object.
Properties of OID
• Its unique
• Its system generated
• Its invisible to the user
• It’s not possible to perform operation on OID
• It’s in mutable i.e. once its generated
Object Structure
• A feature of OODB: objects may have an
object structure of arbitrary complexity.
• The state of a complex object may be
constructed from other objects.
• Object triple representation: (i, c, v)
I= is Object identifier(OID)
C=is a type constructor
V=is the object state
Type Constructors
• Every object has internal structure that can be specified
by using 6 types of type constructor (AST LAM)
1. ATOM
2. SET
3. Tuples:-
4. List :
5. ARRAY: - It’s similar
6. MULTISET or bag: -
1. ATDM: - Internal structure of object consists of
automatic values that may be of type integer float,
character, string, data etc.
Type Constructors con…
2. SET:- Internal structure of object, consist of collection of OID’s of
other objects that may be constructed from different type constructor its
denoted by {i1 , i2 , i3 , …}
3. Tuples:- Internal structure of object, consist of collection of OID’s
other objects that may be constructed from different type constructor its
denoted by {a1 : i1 ; a2 : i2 ; a3 : i3, …} where a1 , a2 , a3 , … be the
attributers & i1 , i2 , i3 be OID’s
4. List :- Its similar to the set but it’s an ordered collection its denoted by
{ i1 , i2 , i3 , …}
5. ARRAY: - It’s similar to list but it has limitations I.e. it’s of fixed size.
6. MULTISET or bag: - It’s similar to the set but it may contain
duplicate. Any object structure is represented
Encapsulation of Operation, Methods
• Encapsulation in object oriented means an object
contains both the data structures and the methods to
manipulate the data structures.
• The data structures are internal to the object and are
only accessed by other objects through the public
methods.
• Encapsulation ensures that changes in the internal data
structure of an object does not affect other objects
provided the public methods remains the same.
Encapsulation provides a form of data independence.
Methods
• Methods are procedures, internal to each object,
which alter an objects private state. State here means
the values of the data items of the object in question.
• Examples of methods
• Some examples of commonly found methods are as
follows:
 Constructors:
 Destructors:
 Transformers:
Method cont…
• Constructors: These are used whenever a new instance
of an object is created. They initialize the data items
contained within the object instance. Destructors: These
methods are used when an instance of an object is
deleted. They ensure that any resources that are held by
the object instance, such as storage space, are released.
• Transformers: These methods are used to change an
object's internal state. There may be a number of
transformer methods used to bring about changes to the
data items of an object instance.
Examples of methods
• . These methods are fragments of program code,
which are used to carry out operations relevant to
the object in question.
• For example, a Customer object, as well as having the
traditional data items we might expect to see in a
Customer table, may include operations such as
• CREATE A NEW CUSTOMER INSTANCE (constructor),
REMOVE A CUSTOMER INSTANCE (destructor),
CHANGE CUSTOMER DETAILS (transformer), etc.
Class Hierarchies and Inheritance
• Attributes and operations are together called
functions (attributes resemble functions with zero
arguments)
• Type: a type name and a listing of the names of its
visible (public) functions:
– PERSON: Name, Address, Birthdate, Age, SSN
• Defining a type:
– defining all functions
– Implementing them as attributes or as methods
extends
• Extends: collections of objects of the same
type
• It’s common in database application that each
type or subtype will have an extent associated
with it, which holds the collection of all
persistent object of that type or subtype.
• Persistent collection, transient collection
Complex Objects
• There are Two main types complex objects:
1. structured complex objects and
2. Unstructured complex objects
• Structured complex objects:
– made up of components
– Defined by applying available type constructors recursively
• Unstructured complex objects :
a data type requires a large amount of storage (image or large
textual object)
• ODBMS can be viewed as having a extensible type system.
• DBMS internals provide the underlying storage and
retrieval capabilities.

You might also like