AS8.2 - Database Management Systems
AS8.2 - Database Management Systems
Computer Science
Databases
AS 8.2 Database Management Systems
International A Level
Overview
• AS 8.1: Data Storage and Retrieval
• AS 8.1: File-based Approach
• AS 8.1: Relational Database Approach
• AS 8.1: Entity-relationship Diagrams
• AS 8.1: Normalisation
• Database Management Systems
• AS 8.3: DBMS Languages (DDL, DML, DCL, TCL)
• AS 8.3: Structured Query Language (SQL)
Features of a DBMS
• Query Processor
• Creation and execution of SQL queries
• Developer Interface
• Direct access to create and modify database tables, indexes, etc
• Data Dictionary
• Store of metadata; definitions of tables, attributes, and details of physical storage
• Indexes
• Internal tables to improve query performance
• Maintenance Tools
• Integrity checking
• Backup and Restore
Conceptual Architecture of a DBMS
Each Database Management System has its
External Level own internal architecture – for large
commercial DBMS such those produced by
Oracle, IBM, and Microsoft, this architecture is
proprietary.
Physical Storage
Conceptual Architecture of a DBMS
There are multiple user views of data
External Level Each user view has a particular purpose, and
excludes data which are irrelevant to a
particular type of user (or which should not be
accessed by a particular type of user)
Physical Storage
Conceptual Architecture of a DBMS
External Level
External Level
Conceptual Level
Internal Level
Physical Storage
High-level Structure of a DBMS
Users Applications
Interface Interface
Monitoring &
Query Processor Access Controls
Reporting
Interface
Other DBMS
Storage Engine
Tells us the lowest-priced item we sell, using the column names "Product
Name" and "Price" instead of the database attribute names
Sorting Rows – ORDER BY
[ASC/DESC]
SELECT * FROM Product ORDER BY UnitPrice DESC
Gives the total number of items ordered on each Order ID, grouped by Order ID
Joins Practical 1 – List of Orders
• Display a list of orders, showing:
• OrderID (from the CustomerOrder Table)
• FirstName (from the Customer Table)
• OrderDate (from the CustomerOrder Table)
Joins Practical 1 – List of Orders
SELECT CustomerOrder.OrderID, Customer.FirstName, CustomerOrder.OrderDate
FROM CustomerOrder
JOIN Customer ON CustomerOrder.CID = Customer.CustomerID
Joins Practical 1 – List of Orders
(Alternative)
SELECT CustomerOrder.OrderID, Customer.FirstName, CustomerOrder.OrderDate
FROM Customer, CustomerOrder
WHERE CustomerOrder.CID = Customer.CustomerID
Joins Practical 2 – List of Products on
Order X
• Display a list of products on customer order number 101 showing:
• Name (from the Product Table)
• Unit Price (from the Product Table)
• Amount on Order X (from OrderLine Table)
• "Order Number" for Order X (from OrderLine Table)
Joins Practical 2 – List of Products on
Order X
SELECT Product.Name, Product.UnitPrice, OrderLine.ProductAmount,
Orderline.OID AS "Order Number"
FROM Product
JOIN OrderLine ON Product.ProductID = OrderLine.PID
WHERE OrderLine.OID = 101
Joins Practical 3 – List of Products by
Total Ordered
• Display a list of products, their prices, and the total number of each
ordered, sorted from the most-ordered to the least-ordered product,
showing:
• Name (from the Product Table)
• Unit Price (from the Product Table)
• Total ordered
Joins Practical
SELECT Product.Name, Product.UnitPrice, SUM(OrderLine.ProductAmount)
AS "Total Ordered"
FROM Product JOIN OrderLine ON Product.ProductID = OrderLine.PID
GROUP BY Product.Name
ORDER BY "Total Ordered" DESC
One Note
• I have placed a skeleton Python solution for the shop database on
OneNote in the SQL Exercises Section
• You will also find all of the Additional SQL Features in the same
Section