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 3pi
The Hierarchy of Data
Hierarchy of data Example (Project database) ¡ 098 - 40 - 1370 Fiske, Steven 01-05-1985 Files 549 - 77 - 1001 Buckley, Bill 02-17-1979 * (Personnel file) , 005 - 10 - 6321 Johns, Francine 10-07-1997 | ; (Record containing
098 - 40 - 1370 Fiske, Steven 01-05-1985 : son fast and first
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”
Trang 8
đễ:w Tradiional Files vs Databases:
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
Trang 13
Relational Database Model
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
Trang 16Keys o Smallest set of attributes can be used to identify a row in a table
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
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
Trang 18° Primary and Foreign Keys CUSTOMER — CN * * * ( Customer_ ID ) Customer Name | Customer_ Address City State Postal_Code ~~ ——” Ỉ Primary Key ORDER
— 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
Trang 20
Data Modelling
Oo To analyse and moael the logical structures and relationships between data items
Oo To assist the data design process
Trang 23Database Design Oo Convert entity relationship model to relational model
=» Convert entities into tables
=» Identify keys and attributes
=» Create referential keys (foreign keys) for
relationships
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)
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
Trang 26
Distriouted Databases