Jeffrey A. Hoffer, V. Ramesh, Heikki Topi: Modern Database Management 12 Edition
Jeffrey A. Hoffer, V. Ramesh, Heikki Topi: Modern Database Management 12 Edition
Jeffrey A. Hoffer, V. Ramesh, Heikki Topi: Modern Database Management 12 Edition
Consists of:
• Data structure
• Tables (relations), rows, columns
• Data integrity
• Mechanisms for implementing business rules that maintain
integrity of manipulated data
• Data manipulation
• Powerful SQL operations for retrieving and modifying data
SQL - Structured Query Language
The standard for relational database management
systems (RDBMS)
History of SQL
• 1970 – E. F. Codd develops relational database concept
• 1974-1979 – System R with Sequel (later SQL) created at IBM Research Lab
• Current – SQL is supported by most major database vendors but is still not
completely portable among different database systems without
adjustments.
SQL Standard:
Basic Purpose:
• Specify syntax/semantics for data definition and manipulation
• Define data structures and basic operations
• Enable portability of database definition and application modules
Benefits:
• Reduced training costs
• Productivity
• Application portability
• Application longevity
• Reduced dependence on a single vendor
• Cross-system communication
SQL ENVIRONMENT
An instance of SQL DBMS
Schema:
The structure that contains descriptions of objects created by a user (base tables, views, constraints)
SQL ENVIRONMENT
CUSTOMERNAME CUSTOMERADDRESS
ProductDescription ProductStandardPrice
SELECT ProductDescription, ProductStandardPrice End Table 175
FROM Product_T Computer Desc 250
WHERE ProductDescription LIKE ‘%e%’ Coffee Table 270
Dining Table 500
Using Functions
ProductDescription ProductStandardPrice
• Use of functions:
End Table 175
Computer Desc 250
Coffee Table 270
Dining Table 500
ProductStandardPrice
175
SELECT ProductStandardPrice 250
FROM Product_T;
270
500
Using Functions
ProductDescription ProductStandardPrice
• Use of functions:
End Table 175
Computer Desc 250
Coffee Table 270
Dining Table 500
Difference
SELECT ProductStandardPrice – PriceAvg AS Difference
-124
FROM Product_T, (SELECT AVG(ProductStandardPrice) AS PriceAvg
-49
FROM Product_T);
-29
201
Quiz
• What would the new rental_rate be for each movie, if you increase the current one by 50%?
ProductID ProductDescription
3
Using NULL
ProductID ProductDescription ProductStandardPrice
A null value means that a column is
missing a value; the value is not 1 End Table 175
zero or blank or any special code.
2 Computer Desc 250
3 270
There simply is no value.
4 Dining Table 500
ProductID ProductDescription
Using NULL
ProductID ProductDescription ProductStandardPrice
A null value means that a column is
missing a value; the value is not 1 End Table 175
zero or blank or any special code.
2 Computer Desc 250
3 270
There simply is no value.
4 Dining Table 500
ProductID ProductDescription
1 End Table
2 Computer Desc
4 Dining Table
Using Function and NULL
ProductID ProductDescription ProductStandardPrice
answer answer
4 3
SELECT–Boolean Operators
29
SELECT–Boolean Operators
With parentheses…these override the normal
precedence of Boolean operators
30
Boolean query with use of parentheses
OR is processed first:
Tables or Desks
then AND
with price >300
31
Quiz