Академический Документы
Профессиональный Документы
Культура Документы
Cardinality = 5
Degree = 7
Primary Key is SSN
Select …..
From P, SP
Where P.weight = SP.qty
Both are valid queries in SQL, but second one
makes no sense!!
n Domains implemented as Data-Types?
S1
S1 P1
P2 S2
S1 P2
S3
S2 P3
P2 S4
S2 P4
P4
S2 P1 S1
S2 P2 S4
S3 P2 P1
S2
S4 P2 P2
S4 P4 P4
Shipment Parts
© Prof. Navneet Goyal, BITS, Pilani
Join
A1 B1 B1 C1
A2 B1 B2 C2
A3 B2 B3 C3
A1 B1 C1
A2 B1 C1
NATURAL
JOIN A3 B2 C2
- We want to find out the sales amount for all of the stores
- If we do a regular join, we will not be able to get what we want because we
will have missed "New York," since it does not appear in the
Store_Information table store_name SALES
SELECT A1.store_name, SUM(A2.Sales) SALES Boston $700
FROM Geography A1, Store_Information A2 New York
WHERE A1.store_name = A2.store_name (+) Los Angeles $1800
GROUP BY A1.store_name San Diego $250
NVL Function
nIn Oracle/PLSQL, the NVL function lets you substitutes a value when a null
value is encountered.
NVL (string1, replace_with )
string1 is the string to test for a null value. Replace_with is the value
returned if string1 is null.
Example #1:
select NVL (supplier_city, 'n/a')
from suppliers;
The SQL statement above would return 'n/a' if the supplier_city field
contained a null value. Otherwise, it would return the supplier_city value.
Example #2:
select supplier_id,
NVL (supplier_desc, supplier_name)
from suppliers;
This SQL statement would return the supplier_name field if the
supplier_desc contained a null value. Otherwise, it would return the
supplier_desc.
Example #3:
select NVL (commission, 0)
from sales;
This SQL statement would return 0 if the commission field contained a null
value. Otherwise, it would return the commission field.
Atomicity of Values
n Cell values are atomic
n 1 NF
n Repeating groups
n Nested relations