0% found this document useful (0 votes)
14 views33 pages

Lesson23 Database

The document provides an overview of databases, including definitions of data, database management systems (DBMS), and data organization structures. It explains the importance of databases for organizations, highlighting benefits such as data sharing, security, and integrity. Additionally, it covers different types of database models, query languages, and practical exercises for creating and managing databases using SQL.

Uploaded by

snowsweater666
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)
14 views33 pages

Lesson23 Database

The document provides an overview of databases, including definitions of data, database management systems (DBMS), and data organization structures. It explains the importance of databases for organizations, highlighting benefits such as data sharing, security, and integrity. Additionally, it covers different types of database models, query languages, and practical exercises for creating and managing databases using SQL.

Uploaded by

snowsweater666
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/ 33

Database

Data
Data: facts or observations about people, places, things, and
events
The data becomes much richer!
 The physical view: focuses on the
actual format and location of the
data.
 The logical view: focuses on the
meaning, content, and context of the
data.
Database(DB)
Database: a large structured collection of data that is stored
and accessed electronically.
It is essentially an organized warehouse for storing, retrieving,
and managing large amounts of information.
Data redundancy
Data integrity
Why is the database needed?
For an organization, what are the benefits of having databases?
Sharing
Security
Less data redundancy
Data integrity
Data Organization
character

field

record

table

database
Data Organization
Character: A character is the most basic logical data element.
Field: The next higher level is a field or group of related characters. A
data field represents an attribute (description or characteristic) of
some entity (person, place, thing, or object).
Record: A record is a collection of related fields. A record represents
a collection of attributes that describe an entity.
Table: A table is a collection of related records.
Database: A database is an integrated collection of logically related
tables.
Data Organization
Database Management
system(DBMS)
In order to create, modify, and gain access to a database, special
software is required. This software is called a database
management system(DBMS).
Access, SQL Server, Oracle……
Database Management
system(DBMS)
DBMS software is made up of five parts:
1. The DBMS engine provides a bridge between the logical view of the data and
the physical view of the data.
2. The data definition subsystem defines the logical structure of the database.
3. The data manipulation subsystem provides tools for maintaining and
analyzing data. Specific tools include query-by-example and specialized programming
languages called structured query languages (SQL).
4. The application generation subsystem provides tools to create data entry
forms, working with programming language, such as C or VB.
5. The data administration subsystem helps to manage the overall database.
Development
• Before the mid-1950s
Manual Management • Data was stored on physical media
• No OS
• Limitation on hardware and software

• 1950s-1960s
• large-capacity storage devices, hard disk
File System • Operating systems were introduced
• Data could be stored and retrieved in a more structured way
• there was still a high degree of redundancy and inconsistency

• development of specialized DBMS


DBMS • massive data
• efficient data storage, retrieval, and security mechanisms
DBMS Structure
Name 0.4
abstraction Age Pikachu
Height 2
Weight 6
entity in real world conceptual model data
DBMS Structure
DBMS programs are designed to work with data that is
logically structured or arranged in a particular way. The
arrangement is known as the database model.
Hierarchical database
Network Database
Relational Database
Hierarchical Database
In a hierarchical database, fields or records are
structured in nodes.
◦ Nodes are points connected like the branches of an upside-down
tree.
◦ Each entry has one parent node, although a parent may have
several child nodes.
◦ This is sometimes described as a one-to-many relationship.
Hierarchical Database
Network Database
A network database also has a hierarchical
arrangement of nodes. However, each child node
may have more than one parent node.
This is sometimes described as a many-to-many
relationship.
It may be traced down through different branches.
Network Database
Relational Database
the data elements are stored in different tables, each
of which consists of rows and columns.
A table and its data is called a relation.
All related tables must have a common data item (key
field) enabling information stored in one table to be
linked with information stored in another.
Relational Database
DBMS Structure
1:1 relationship 1:n relationship m:n relationship
entity1 entity1 entity1

1 1 m

relationship relationship relationship

1 n n
entity2 entity2 entity2
DBMS Structure
course

employee
1
teaching 1 n
m n leader

teacher textbook
Entity-Relationship Diagram
ER diagram is a graphical representation used to establish a
data model in the conceptual design phase of database
system development.

entity attribute relationship


Entity-Relationship Diagram
Fulfill the following ER diagram

Course class
Course
cerdit score
id name

course
m select
n Student

1
teach

teacher textbook
course

m
Relational table
select
key CID CName Credit CID SID score
01 CS 4
02 Math 6
01 03001
n
01 03123
03 Chinese 4 01 02010 stu
04 Chemistry 4 02 03001 80
02 02010 98
02 02221 89
SID SName Class
03 03123
03001 Anna 2
03 02221
03123 Bob 4
04 03001 92
02010 Mike 10
04 02010 88
02221 Jeff 7
Query Languages
Query languages enable nonprogrammers to use certain
easily understood commands to search and generate
reports from a database. One of the most widely used query
languages is SQL (Structured Query Language).
Data Hierarchy
A collection of related Table
Record File Database
(Table)

SID Name Gende Date of National


r Birth ity
Record 4939 Alice F 97-12-8 Canada

4357 Jenny F 96-3-7 USA

1675 David M 95-7-2 China

Field
Field Type, Primary
Key
SID Name Gender Date of Nation
Birth ality
4939 Alice F 97-12- Canada
8
4357 Jenny F 96-3-7 USA

1675 David M 95-7-2 China

Num String Boolean/ Date String


String

Field Type
Primary Key, which uniquely identifies a record
Relational Database,
Foreign Key
Table 1: Student

SID Name Gender Date of Nationa


Birth lity
4939 Alice M 77-12-8 USA
Foreign Key (Table 1) / Primary Key (Table 2)
Table 2: Nation

National National Languag


A foreign key
ity Code e in the table
USA 0049 English where the link
begins.
Structured Query Language
(SQL)
SID Name Gender Date of Nation
Table: Student
Birth ality
4939 Alice F 97-12- Canada
8
4357 Jenny F 96-3-7 USA
1675 David M 95-7-2 USA
Select, Select SID, Name from Student where Gender = “M”
Insert,
Update, Field table condition
Delete
Statements SID Name
1675 David
SID Name Gender Date of Nationality
Birth
4939 Alice F 97-12-8 Canada
Table: Student 4357 Jenny F 96-3-7 USA
1675 David M 95-7-2 USA

Insert into Student values (1234, “Jason”, “M”, #96-5-23#, “China”)

Table Update values of fields


SID Name Gender Date of Nationalit
Select, Birth y
Insert,
Update, 4939 Alice F 97-12-8 Canada
Delete
4357 Jenny F 96-3-7 USA
Statements
1675 David M 95-7-2 USA

1234 Jason M 96-5-23 China


Table: Student

SID Name Gender Date of Nationality


Birth
4939 Alice F 97-12-8 Canada
4357 Jenny F 96-3-7 USA
1675 David M 95-7-2 USA

Update Student set Nationality = “China” where Gender = “F”

Table Update values of fields Condition

SID Name Gender Date of Nationalit


Select, Birth y
Insert,
Update, 4939 Alice F 97-12-8 China
Delete
Statements 4357 Jenny F 96-3-7 China

1675 David M 95-7-2 USA


Table: Student

SID Name Gender Date of Nationality


Birth
4939 Alice F 97-12-8 Canada
4357 Jenny F 96-3-7 China
1675 David M 95-7-2 USA

Delete From Student where Name = “Alice”

Table Condition

SID Name Gender Date of Nationalit


Select, Birth y
Insert,
Update, 4357 Jenny F 96-3-7 China
Delete
Statements 1675 David M 95-7-2 USA
Exercise
Create a new database using MS Access
Create a new table with following field definition
ID Name Gender Nation Age
Primary Key Number Text Text Text Number

Add the following records:


2332 Johnson M China 33
3456 Emily F Germany 19
6534 Amy F USA 17
Use SQL statement
Add a new record as follow:
ID Name Gender Nation Age
7890 Alicia F USA 20

Select the ID and name whose age is less than 20.


Change the Gender of all students from USA to
male.

You might also like