Introduction to Computing: Lecture 6 - Databases presents about The Hierarchy of Data, Keys and Attributes, The Traditional Approach To Data Management, Database, Database Approach, Traditional Files vs. Databases, Database Management Systems.
Trang 2
Databases
Trang 3pi
The Hierarchy of Data
Hierarchy of data Example
, 005 - 10 - 6321 Johns, Francine 10-07-1997
| ; (Record containing
098 - 40 - 1370 Fiske, Steven 01-05-1985 : son fast and first
name, hire date)
Trang 4
Keys and Attributes
Employee # | Lastname First name Hire date Dept number 005-10-6321 Johns Francine 10-07-1997 257 549-77-1001 Buckley Bill 02-17-1979 632 098-400-1370 Fiske Steven 01-05-1985 598
7 Key field
Aiwlxsse
(fields)
Entities (records)
Trang 6
Database
Oo “A collection of data, generally related to
some subject or topic area and structured so
as to allow relationships to be established between separate data items accoraing to the various needs of users”
G Knott & N Waites, Computing 3" edition
Trang 8
đễ:w Tradiional Files vs Databases:
Pros and Cons
Trang 9
5m Database Management Systems
(DBMS)
o Databases are usually managed by DBMS
o DBMS: A collection of programs that controls and
prevents accidental or deliberate corruption of data
by other application programs
o Functions of DBMS
=» dStore, query and update data
=» Manage transaction
=» Control concurrent access to database
=» Maintain data consistency and integrity
Trang 13
Relational Database Model
Data table 1: Project table
Trang 14
Relational Models
o Describe data using a standard tabular format
with all data elements placed in two- dimensional tables, called relations, that are
the logical equivalent of files
» Domain
=» selecting
=» Projecting a» Joining
Trang 15BK Linking Database Tables to Answer
Trang 16
Oo Single key: composed of only one attribute
co Composite key: composed of two or more
attributes
o A table can have many keys
Oo Primary key: a selected key
o Candidate keys: other keys, except primary key
Trang 17
Foreign Keys
oO If atable uses the primary key of another
table as attribute to refer to a row in the other table, the attribute is called referential
key or foreign key
Trang 18
— Ss Foreign Key (implements 1:N
Order_!ID Order Date ( Customer_!ID — lati hip bet t d
— "_— —— relationship between Customer an
order)
ORDER LINE Combined, these are a composite
| primary key (uniquely identifies the Korert® Croduo 2 ) Ordered_Quantty | order line) individually they are
+ foreign keys (implement M:N
relationship between order and PRODUCT product)
Product_ ID Product_Description | Product Finish | Standard_ Price | Product Line ID
Trang 19
Database Design and Construction
Trang 20
Data Modelling
Oo To analyse and moael the logical structures
and relationships between data items
Oo To assist the data design process
o Entity Relationship Model is commonly used
as a data modelling tool
Trang 23=» Convert entities into tables
=» Identify keys and attributes
=» Create referential keys (foreign keys) for
relationships
o Decide data types and length for attributes
Trang 24
Data Normalisation
Oo A step-by-step process for analysing data
into its constituent entities and attributes
o To improve database efficiency and to
maintain data consistency and integrity
Oo Commonly, three normal forms are used:
a First normal form (1NF)
=» second normal form (2NF)
=» Third normal form (3NF)
Trang 25
Database Construction
o Use tools, eg MS Access
o Use Structured Query Language (SQL)
=» Data Definition Language
o for defining database and database tables
o Commands: create database, create table, alter table,
drop table, etc
» Data Manipulation Language
o For manipulating the data within data
o Commands: select, insert, update and delete
Trang 26
Distriouted Databases
o In distributed database system, the
database is subdivided over multiple computer systems but appear to users