Ict L6 Exercise
Ict L6 Exercise
Ict L6 Exercise
IICT Lecture 06
What is a Database?
Name
• Unary operation
• Insert Operation: Inserts new tuple into the relation
Delete operation
• Unary operation
• Delete Operation: Deletes tuple from the relation
Update operation
• Unary operation
• Update Operation: Changes the values of some attributes
of a tuple
Select operation
• Unary operation
• Select Operation: Uses some criteria to select
some tuples from the original relation
Project operation
• Unary operation
• Project Operation: Creates relation in
which each tuple has fewer attributes
Join operation
• Binary operation
• Join Operation: Takes two relation and combine them
based on common attribute
Union operation
• Binary operation
• Union Operation: Creates new relation in which each
tuple is either in the first relation, the second relation or
in both
Intersection operation
• Binary operation
• Intersection Operation: Creates new relation in
which each tuple is in both relations.
Difference operation
• Binary Operation
• Difference Operation: Creates new relation where the
new tuples are in the first relation but not in the
second.
Database Management System
• A database management system (DBMS) is
system software for creating and managing
Database.
• The DBMS provides users and programmers
with a systematic way to create, retrieve,
update and manage data.
• DBMS allow all the operations on database
discussed in previous slides
• Inserte, Delete, retrieve, Union, Join etc…
STRUCTURED
QUERY
LANGUAGE
SQL
update RELATION-NAME
set attribute1 = value1 attribute 2 = value2 …
where criteria
Update (Example)
update COURSES
set unit = 6
where No = “CIS51”
4. Select
• SQL Select Operation format
select *
from RELATION-NAME
where criteria
Select (Example)
select *
from COURSES
where Unit = 5
5. Project
• SQL Project Operation format
select attribute-list
from RELATION-NAME
Project (Example)
select attribute-list
from RELATION NO1, RELATION NO2
where criteria
Join (Example)
select *
from RELATION NO1
union
select *
from RELATION NO2
Union (Example)
select *
from CIS15-Roster
union
select *
from CIS52-Roster;
8. Intersection
• SQL Intersection Operation format
select *
from RELATION NO1
intersection
select *
from RELATION NO2
Intersection (Example)
select *
from CIS15-Roster
intersection
select *
from CIS52-Roster;
9. Difference
• SQL Difference Operation format
select *
from RELATION NO1
minus
select *
from RELATION NO2
Intersection (Example)
select *
from CIS15-Roster
minus
select *
from CIS52-Roster;
OTHER
DATABASE
MODELS
The levels of Data
Database One or more tables
Table A collection of Records
(relation)
Record A group of related fields
Field One or more character
Character At least 8 bits
Bit 0 or 1
5 characteristics of Good Database
Data Integrity Ensuring data is valid
Data Independence Data is separated from software
Avoiding data Repetition of input data is avoided
Redundancy
Data Security Data is not accessible to unauthorized
users
Data Maintenance Set procedures for adding ,deleting …
records for the purpose of optimization
How To Write And Run SQL
Query
• 1. After launching Microsoft Access, either select "more" to open an existing database or
click "Blank Database" to create a New database. If you are creating a new database, type a
name (any name is fine) for your database in the “File Name” box. Next, click the “Create”
button.
• Note: If you are selecting an existing database (i.e the downloaded course database), browse
(locate where you saved the database on your computer) for the database after you click
"more".
• 2. Once Access opens, Click “Create” from the menu running across the top of the screen.
• 3. Next, Click the “Query Design” button.
• 4. You'll see a “Show Table” dialog box. Click close on this dialog box without selecting any
tables.
• 5. Select the “SQL View” or “SQL” button near the top left of the screen.
• 6. Use the "SQL View" or “SQL” button to select “SQL View”. (Click the down arrow
located on this button to locate “SQL View”).
• 7. Type your SQL commands in this view (SQL View).
• To run a command, click the "Run" button.