You are on page 1of 34

ADVANCED

DATABASE
SYSTEMS
[CC6001]

Week 01 Week 1
Your journey at Islington College?

 Level 4
Introduction to Information Systems

 Level 5

 Databases

 Level 6

 Advanced Database Systems


Development
Why is it covered every year?
Why is it important?

Application Work Related Final Year


Development Learning Project
• Study MS • Work with • Design and
SQL Server projects develop
as database which have database
and develop database to and
applications connect and application
work with on top of it
General Module Specification

 Level6 Module
 30 Credit Hours Consists of 3 Parts
◼ Theoretical aspects of Database
◼ Practical approach using SQL
◼ Database Design Environment
Delivery Methods

 Lecture
 Concepts and General
Understanding
 Workshop
 Practical Implementation
Assessment

 Course Work – Week 18


 40%
 Class Test (SQL) – Week 24
 20%
 Unseen Exam – Week 31
 40%
Why this Subject?
What we have studied?

Historical Developments

Structured Query Language

Database Design Process


Writing Basic
SQL SELECT Statements

Copyright © Oracle Corporation, 2001. All rights reserved.


Capabilities of SQL SELECT Statements

Projection Selection

Table 1 Table 1

Join

Table 1 Table 2
Copyright © Oracle Corporation, 2001. All rightsreserved. 1-3
Basic SELECT Statement

SELECT *|{[DISTINCT] column|expression [alias],...}


FROM table;

• SELECT identifies what columns


• FROM identifies which table

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-4


Selecting All Columns

SELECT *
FROM departments;

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-5


Selecting Specific Columns

SELECT department_id, location_id


FROM departments;

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-6


Writing SQL Statements

• SQL statements are not case sensitive.


• SQL statements can be on one or more lines.
• Keywords cannot be abbreviated or split
across lines.
• Clauses are usually placed on separate lines.
• Indents are used to enhance readability.

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-7


Arithmetic Expressions

Create expressions with number and date data by


using arithmetic operators.

Operator Description

+ Add

- Subtract

* Multiply

/ Divide

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-8


Using Arithmetic Operators

SELECT last_name, salary, salary + 300


FROM employees;

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-9


Operator Precedence

_
* / +
• Multiplication and division take priority over
addition and subtraction.
• Operators of the same priority are evaluated from
left to right.
• Parentheses are used to force prioritized
evaluation and to clarify statements.

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-10


Operator Precedence

SELECT last_name, salary, 12*salary+100


FROM employees;

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-11


Using Parentheses

SELECT last_name, salary, 12*(salary+100)


FROM employees;

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-12


Defining a Null Value

• A null is a value that is unavailable, unassigned,


unknown, or inapplicable.
• A null is not the same as zero or a blank space.
SELECT last_name, job_id, salary, commission_pct
FROM employees;

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-13


What is the difference between null and empty
value?
Null Values
in Arithmetic Expressions
Arithmetic expressions containing a null value
evaluate to null.
SELECT last_name, 12*salary*commission_pct
FROM employees;

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-15


Defining a Column Alias

A column alias:
• Renames a column heading
• Is useful with calculations
• Immediately follows the column name - there can
also be the optional AS keyword between the
column name and alias
• Requires double quotation marks if it contains
spaces or special characters or is case sensitive

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-16


Using Column Aliases

SELECT last_name AS name, commission_pct comm


FROM employees;

SELECT last_name "Name", salary*12 "Annual Salary"


FROM employees;


Copyright © Oracle Corporation, 2001. All rightsreserved. 1-17
Concatenation Operator

A concatenation operator:
• Concatenates columns or character strings to
other columns
• Is represented by two vertical bars (||)
• Creates a resultant column that is a character
expression

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-18


Using the Concatenation Operator

SELECT last_name||job_id AS "Employees"


FROM employees;

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-19


Literal Character Strings

• A literal is a character, a number, or a date


included in the SELECT list.
• Date and character literal values must be enclosed
within single quotation marks.
• Each character string is output once for each
row returned.

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-20


Using Literal Character Strings

SELECT last_name ||' is a '||job_id


AS "Employee Details"
FROM employees;

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-21


Duplicate Rows

The default display of queries is all rows, including


duplicate rows.
SELECT department_id
FROM employees;

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-22


Eliminating Duplicate Rows

Eliminate duplicate rows by using the DISTINCT


keyword in the SELECT clause.
SELECT DISTINCT department_id
FROM employees;

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-23


Displaying Table Structure

Use the iSQL*Plus DESCRIBE command to display


the structure of a table.

DESC[RIBE] tablename

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-24


Displaying Table Structure

DESCRIBE employees

Copyright © Oracle Corporation, 2001. All rightsreserved. 1-25


End of Part 1

You might also like