Uploaded by Operator Queen

CSC 303 - Database System - Main Material

advertisement
CSC 303
DATABASE
SYSTEMS
An approach of organizing data in such a way that it can be easily
accessed, managed and updated.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
COURSE CONTENTS
•
•
•
•
•
Introduction to Database concepts, approaches and tools
File systems and Database Management System
Database design.
The entity-relationship model,
Functional dependencies, normal forms, design theory and
optimization.
• Other topics may include concurrency control, distributed
systems security, knowledge base and concept of objectoriented database systems.
.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.1 DATABASE CONCEPTS
 Database is thought of as a kind of electronic filing
cabinet or an electronic filing system.
 In filling system we have what is called File and Record. In
file we have records, and in record we have fields
Record
Field Names
File
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
DATABASE CONCEPTS
 A File is collection of Records;
 A Record is a collection of Fields or one complete set of
fields;
 A Field is a single piece of information.
 A Table is a set of data elements (values) using a model of
vertical columns (identifiable by name) and horizontal
rows.
 A table has a specified number of columns, but can have
any number of rows.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
OVERVIEW OF
DATABASE SYSTEM
1.2 Database System (DB): is an organized collection
of data that are organized in such a way that it can be
easily accessed, managed and updated.
• It is restrictively, is a collection of schemas, tables,
queries, reports, views, and other elements.
• A database schema defines how data is organized
within a relational database.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
OVERVIEW OF
DATABASE SYSTEM
• A Table is a set of data elements (values) using a model of
vertical columns (identifiable by name) and horizontal
rows.
• What is the difference between Schema and Table?
A database schema describes the structure and
organization of data in a database system, while a table is
a data set in which the data is organized in to a set of
vertical columns and horizontal rows.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
OVERVIEW OF
DATABASE SYSTEM
• Assignments
• What is queries, reports and views data base?
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
OVERVIEW OF
DATABASE SYSTEM
• Answers to Assignments
• A query can either be a request for data results from your database or for action on the
data, or for both.
• It can give you an answer to a simple question, perform calculations, combine data from
different tables, add, change, or delete data from a database.
• A report is a database object that comes in handy when you want to present the
information in your database for any of the following uses: Display or distribute a
summary of data. Archive snapshots of the data. Provide details about individual records.
• A view is a virtual table whose contents are defined by a query. Like a table, a view
consists of a set of named columns and rows of data. Unless indexed, a view does not
exist as a stored set of data values in a database
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
OVERVIEW OF
DATABASE SYSTEM
1.3 Primary goal of DB
 Minimizes data redundancy to a great extent
 Control inconsistency of data to a large extent
 Sharing of data
 To ensure data integrity and security
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.4 CLASSIFICATION OF
DATABASES
 In computing, databases are classified
according
to
their
organizational
approach.
Ranging from the most
prevalent
approach,
the
relational
database to a distributed database, cloud
database or NoSQL database and OOD
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.4.1 PREVALENT APPROACH
Traditional
Relational
Database
Manageme
nt
System
(DBMS)
File
Management
System
(FMS)
(allows access
to single files or
tables at a time)
(allows access to
multiple files or
tables at a time)
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.4.2. RELATIONAL DATABASES
 Relational Databases (RD) are made up
of a set of tables with data fits into a
predefined category. RD are easy to
extend, and a new category can be added
after the original database creation
without requiring that you modify all the
existing applications unlike the FMS.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.4.2. RELATIONAL DATABASES contd..
 The most popular form of
database today is the relational
database. Popular examples of
relational databases are Microsoft
Access, MySQL, and Oracle
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.4.3. DISTRIBUTED
DATABASE
 Distributed Database: is a database in which
portions of the database are stored in
multiple physical locations, and which
processing is dispersed or replicated among
different points in a network
 Distributed databases can be homogenous
or heterogenous:
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
DISTRIBUTED DATABASES contd..
 In homogenous distributed database system, all the
physical locations
have the same underlying
hardware and run the same operating systems and
database applications.
 In heterogenous distributed database system, the
hardware, operating systems or database applications
may be different at each of the locations.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.4.4. STRUCTURED QUERY
LANGUAGE (SQL)

The primary way to work with a relational database is to use
Structured Query Language, SQL

The Structured Query Language (SQL) is the standard user
and application program interface for a relational database.

As its name implies, SQL is a language that can be used to
work with a relational database.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
STRUCTURED QUERY
LANGUAGE (SQL) contd…

Many database packages, such as Microsoft Access, allow
you to visually create the query you want to construct and
then generate the SQL query for you.
query will retrieve a list of the first and last
 The
Forfollowing
Example:
names of the club presidents:
SELECT "First Name", "Last Name" FROM "Students"
WHERE "Students.ID" = "Clubs.President"
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.4.5. CLOUD DATABASE
 Cloud Database is an optimized database built
for virtualized environment, either in a hybrid
cloud, public cloud or private cloud.
 It provide organizations the opportunity to
support organization applications in a softwareas-a service (SaaS) deployment.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
CLOUD DATABASE
Cloud databases provide benefits such as the
ability to pay for storage capacity and
bandwidth on a per-use basis, and they
provide scalability on demand, along with
high availability.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.4.6. NoSQL DATABASES
 NoSQL databases (Not only SQL): are useful for
large sets of distributed data.
 They are effective for big data performance issues
that relational database are not built to solve.
 They are most effective when organization want to
analyze large chunks of unstructured data or data
stored across multiple virtual servers in the cloud.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.4.7. OBJECT-ORIENTED
DATABASE
 Object-oriented database: this type of
database is organized around objects rather
than actions, and data rather than logic. For
example a multimedia record in a relational
database can be a definable data object, as
opposed to an alphanumeric value
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.4.8 Graph DATABASES ....
 A graph-oriented database, or simply Graph database:
is a type of NoSQL database that uses graph theory to
store, map and query relationships.
 Graph-oriented database are basically collections of
nodes and edges, where each node represent an
entity, and each edge represent a connection between
nodes
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
Graph DATABASES contd ....
 Graph databases are growing in
popularity
for
analyzing
interconnections.
For
example,
companies might use a graph database
to mine data about customers
from social media.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.5 OTHER KEY TERMS
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
1.5 OTHER KEY TERMS IN
DATABASE
Data Management System (DBMS) is
a type of software that allows you to
define,
manipulate,
retrieve
and
manage data stored within a database
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
MODULE TWO
2.0 DATABASE DESIGN



The design of a database is called the schema. It
defines the variable declarations in tables that belong
to a particular database. It requires:
Data Modeling is the first step in database design. It
is simply described as the analysis of data objects and
their relationships to other data objects.
DBMS is a software that allows you to define,
manipulate, retrieve and manage data stored within a
database.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
DATABASE DESIGN
2.1 DATA ABSTRACTION

Typically, a Database Management System provide
users with an abstract view of the system, while it
hides certain details of how the data are stored and
maintained. This is referred to as Data Abstraction

Data abstraction is a process of hiding
implementation details (such as how the data
stored and maintained) and representing only
essential features to simplify user's interaction with
system.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
the
are
the
the
2.2 LEVEL OF ABSTRACTION
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
LEVELS OF ABSTRACTION
 Internal Level or Physical level
The Physical level is the lowest level of abstraction; it
describes how data are stored. At physical level, a customer,
account and employees record can be described as a block of
consecutive storage location.
 Conceptual Level or Logical Level
The Logical level is the next higher level of abstraction; it
describes what data are stored in database and what
relationship exist among those data. At logical level, each of
such record is described by a type of definition.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
LEVELS OF ABSTRACTION
External Level or View Level
• The view level is the highest level of abstraction; it describes
only part of the entire database. It exists to simplify their
interaction with the system.
• Many users of the database system do not need all this
information; instead, they need to access only a part of the
database. For example, tellers in a bank access only that
part of the database has information on customer accounts;
they cannot access information about the salaries of the
employees.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
LEVELS OF ABSTRACTION
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
2.3 ARCHITECTURE OF THE THREE-LEVEL
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
2.4. PROCESS OF DATA MODELLING
Data modeling is the process of creating a data
model for the data to be stored in a Database. Data
model is a conceptual representation of

Data objects

The associations between different data objects

The rules that binds them.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
2.4.1: DATA MODEL
•
Data Model: is the underlying structure of a database. It is the collection of tools for describing
data, data relationships, data semantics and consistency and constraints.
•
Data Model ensure consistency in naming conventions, ensuring quality of the data. It helps to
define the relational tables, primary and foreign keys and stored procedures.
•
It emphasizes on what data is needed and how it should be organized instead of what operations
need to be performed on the data.
•
It helps to build a conceptual model and set the relationship between data items.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
2.4.2 WHY DATA MODELLING?
 For Efficient Computerization
 Reduce Data Redundancy
• Reduce Disk Space Problem
• Reduce volume of data transfer
 For good Objects of Documentation
It describe the computed elements (for the programmer, for the system designer
and end-users)
 To Guaranty Data Integrity
Valid information irrespective of context
This will be further treated in the second materials by
Prof. Amos DAVID http://ui-n2.loria.fr
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
2.5. THE PRIMARY GOAL OF DATA MODEL






Ensures that all data objects required by the database are accurately represented.
Omission of data will lead to creation of faulty reports and produce incorrect results.
A data model helps design the database at the conceptual, physical and logical levels.
Data Model structure helps to define the relational tables, primary and foreign keys and
stored procedures.
It provides a clear picture of the base data and can be used by database developers to
create a physical database.
It is also helpful to identify missing and redundant data.
Though the initial creation of data model is labor and time consuming, in the long run, it
makes your IT infrastructure upgrade and maintenance cheaper and faster.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
2.6. TYPES OF DATA MODELS
THERE ARE MAINLY THREE DIFFERENT TYPES OF DATA MODELS:
1. Conceptual Data Model: This Data Model defines WHAT the system contains.
This model is typically created by Organization stakeholders and Data
Architects. The purpose is to organize, scope and define organization concepts
and rules.
The main aim of this model is to establish the entities, their attributes, and their
relationships.
The 3 basic tenants of Data Model are
Entity: A real-world object
Attribute: Characteristics or properties of an entity
Relationship: Dependency or association between two entities
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
TYPES OF DATA MODELS contd…
For 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
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
TYPES OF DATA MODELS contd…
Characteristics of a conceptual data model



Offers Organization-wide coverage of the business concepts.
This type of Data Models are designed and developed for a business
audience.
The conceptual model is developed independently of hardware
specifications like data storage capacity, location or software
specifications like DBMS vendor and technology. The focus is to
represent data as a user will see it in the "real world."
Conceptual data models known as Domain models create a common
vocabulary for all stakeholders by establishing basic concepts and scope.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
TYPES OF DATA MODELS contd…
2. Logical Data Model: Defines HOW the system should be
implemented regardless of the DBMS. This model is typically created
by Data Architects and Business Analysts. The purpose is to
developed technical map of rules and data structures.
• Logical data model add further
information to the conceptual model
elements. It defines the structure of
the data elements and set the
relationships between them.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
TYPES OF DATA MODELS contd…
The advantage of the Logical data model is to provide a foundation to form the base for the
Physical model. However, the modeling structure remains generic.
At this Data Modeling level, no primary or secondary key is defined. At this Data modeling
level, you need to verify and adjust the connector details that were set earlier for
relationships.
Characteristics of a Logical data model

Describes data needs for a single project but could integrate with other logical data
models based on the scope of the project.

Designed and developed independently from the DBMS.

Data attributes will have datatypes with exact precisions and length.

Normalization processes to the model is applied typically till 3NF.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
TYPES OF DATA MODELS contd…
3. Physical
Data Model: This Data Model
describes HOW the system will be implemented
using a specific DBMS system. This model is
typically created by DBA and developers. The
purpose is actual implementation of the database.
• A Physical Data Model describes the database
specific implementation of the data model. It
offers an abstraction of the database and helps
generate schema. This is because of the richness
of meta-data offered by a Physical Data Model.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
TYPES OF DATA MODELS contd…
This type of Data model also helps to visualize database structure. It helps to model
database columns keys, constraints, indexes, triggers, and other RDBMS features.
Characteristics of a physical data model:





The physical data model describes data need for a single project or application though it
maybe integrated with other physical data models based on project scope.
Data Model contains relationships between tables that which addresses cardinality and
nullability of the relationships.
Developed for a specific version of a DBMS, location, data storage or technology to be
used in the project.
Columns should have exact datatypes, lengths assigned and default values.
Primary and Foreign keys, views, indexes, access profiles, and authorizations, etc. are
defined.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
2.7. MERIT AND DEMERIT OF DATA MODEL
Advantages of Data model:




The main goal of a designing data model is to make certain that data objects
offered by the functional team are represented accurately.
The data model should be detailed enough to be used for building the physical
database.
The information in the data model can be used for defining the relationship
between tables, primary and foreign keys, and stored procedures.
Data Model helps business to communicate the within and across
organizations.

Data model helps to documents data mappings in ETL process

Help to recognize correct sources of data to populate the model
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
MERIT AND DEMERIT OF DATA MODEL
Disadvantages of Data model:




To developer Data model one should know physical data stored
characteristics.
This is a navigational system produces complex application
development, management. Thus, it requires a knowledge of the
biographical truth.
Even smaller change made in structure require modification in the
entire application.
There is no set data manipulation language in DBMS.
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
2.8 DATA MODEL TECHNIQUE
To illustrate the concept of a data model, two
data models techniques will be outlined:
 Entity Relational Model – E-RM
 Relational Model - RM
CSC 303 - DATABASE SYSTEMS - DR FOLA ARANUWA
2.9. Entity Relational Model
 Representing the real world elements with four main concepts
•
Entity
•
Attributes
•
Relation
•
Cardinality
•
Employs graphic representation
•
Intuitive approach
[1:n]
2.9. MODELING PROCEDURE
 Identify an entity
 Develop fully the entity and chose the attributes and identifier
 Establish the relationship (Associate the entity with existing
ones if and where necessary)
 Establish the cardinalities
2.9. MODELING PROCEDURE
Symbol
2.10. RELATION IN NORMAL FORM
In the relation R(X, Y, Z),There is functional dependency between X and Y if
and only if the value of Y is determined by the value of X and the value of X is
unique
Example Person (N°, FN, LN, town, state)
There is FD between town and state
RELATION IN NORMAL FORM
 Relations in 1st normal form
A relation is said to be in 1st normal form if all the attributes are of single values.
•
Relations in 2nd normal form
A relation is in 2nd normal form if and only if it is in 1stnormal form and there is
no FD between a subset of the key and the rest of the attributes.
This mean that the key of the relation must be a minimum key.
•
Relations in 3rd normal form
A relation is in 3rd normal for if it is in 2ndnormal form and there is no FD between
non key attributes.
2.11. Conversion From ERM to RM
•
To each entity corresponds a relation(Entity name relation name)
•
To each attribute of an entity corresponds an attribute of the relation
•
The identifier of the entity becomes the key of the relation
•
For associations of maximum cardinality [1:n], add the key of the relation on
the n side to the relation on the 1 side
•
For associations of maximum cardinality [n:m], a new relation should be
created using the concatenation of the keys of the associated relations as the
key. The attributes of the association should be added as attributes of the new
relation
2.12: CLASS PRACTICAL 1
In a shopping center, a client can buy
one or more articles of various
quantities. Propose an ER model for
representing
the
elements
of
information necessary for billing the
client.
PRACTICAL EXAMPLE 1
ERM
RM
PRACTICAL EXAMPLE 1
2.13. Relational Model
3.1a: STUDENT PRACTICAL PROJECT
 Model the following types of person in the university
• The students
• The members of staff
Be sure to apply the methods for reducing redundancy
and guaranteeing data integrity
3.1b: STUDENT PRACTICAL PROJECT
Practical : University students
Description: Each student has a number, a name, an address
A student is registered for a degree
A student may not register for more than one degree simultaneously
A student may take several degrees from the university
To a degree is associated a set of courses
A degree is managed by a department
A course is offered by only one department
Example of questions
What are the courses associated with a degree ?
What are the courses taken by a student for a degree ?
What are the courses offered by a department ?
Propose an ER model
3.1c: STUDENT PRACTICAL PROJECT
3.1d:. STUDENT PRACTICAL PROJECT
3.1e: STUDENT PRACTICAL PROJECT
Related documents
Download