Documentos de Académico
Documentos de Profesional
Documentos de Cultura
CSC3064
Database Engineering
to retrieve
relationally complete
Updates in SQL:
allows users to insert, delete and modify tables
Stored Procedures(SQL:1999):
Predefined sequences of SQL statements
SQL:2003/2006
Application Programming Interface (API):
ODBC and JDBC provide standard set of DDL/DML
functions
Options:
restrict - specifies that the command must
not be carried out if the component being
deleted is not empty.
cascade the component is removed together
with the components that depend on it.
Constraints in RDBMS
UNIQUE, NOT NULL, CHECK
Entity integrity - Primary keys
Referential integrity - Foreign keys
Primary Keys
A primary key is a set of columns that together
makes each row distinct
No two rows will have the same value of this
primary key (implies that no two rows can be
identical duplicates are disallowed)
Every table must have one primary key
A primary key should not contain a null value since
then it may not be possible to identify some tuples.
Intra-relational constraints1
Foreign Keys
A FOREIGN KEY is an inter-relational constraint
that references one or more rows in the table in
which it is defined to a primary key (strictly a
candidate key) in another table.
Every non-NULL value that exists in a foreign key
attribute must also exist in the table for which it is
the primary key. i.e.:
if B references A, A must exist
Inter-relational constraints-2
If a row of a table with a foreign key is updated or deleted
DELETE CASCADE;
10
Data modification
VALUES (Smith,Penang);
11
Data removal
DELETE FROM Customer WHERE customerName
= Smith;
12
13
SQL Intersection
Find the names of all customers who have both a loan and
SQL Union
Find the names of all customers who have either a loan or an
14
SQL Minus
Return the rows that are in the first table except those rows
15
16
17
18
Outer Joins
Preserve unmatched rows from one or both tables
LEFT [OUTER] JOIN - preserves unmatched rows from
both tables
19
20
21
22
23
24
Built-In Functions
Operate on the set of values in a column of a relation and return a
expression.
25
find the names of all customers who have both a loan and
account at the RHB
SELECT Loan.customerName FROM Loan, Deposit
WHERE Loan.branchName = RHB AND
Deposit.branchName = RHB AND
Loan.customerName = Deposit.customerName;
27
E.g. find the names of all customers who have both a loan
26
28
29
31
30
32
33