Relational Database Management Systems (RDBMS)
This module presents the most commmly used database managment system in use today: the Relational Database Management System (RDBMS). It begins by exploring the underlying basis for RDBMS systems: the relational model and algebra pioneered by Edgar Codd in the ealy 1970s. It then looks at how the relationa model is represented by relational tables, and operated on by Structured Query Language (SQL) the language of relational databases.
Introduction to Database Concepts
This lecture covers the basic concepts of database management system concepts. It begins by describing the characteristics that make using a database managment systems attractive compared to each applicaion developing its own data management scheme. It also describes three roles that occur in managing a DBMS and what functions each role performs.
Next, we look at the different types of architectures for data-centric applicatins and what role a DBMS plays in each type, including 1-, 2-, and 3-tier architectures. We also introduce two logical models for representing information: the Entity-Relationship (ER) model and the Relational model, and look at how the two are related.
Finally, we learn what a schema is and how it relates to the data stored in the database, and the concept of data independence: how the logical schema are independent of their physical representation.
Readings
Class presentation
Tutorial readings
- Database Management System Tutorial -- Introduction from TutorialsPoint (last accessed 2017-09-01).
- Database Management System Tutorial -- Overview from TutorialsPoint (last accessed 2017-09-01).
- Database Management System Tutorial -- Architecture from TutorialsPoint (last accessed 2017-09-01).
- Database Management System Tutorial -- Data Models from TutorialsPoint (last accessed 2017-09-01).
- Database Management System Tutorial -- Schemas from TutorialsPoint (last accessed 2017-09-01).
- Database Management System Tutorial -- Data Independence from TutorialsPoint (last accessed 2017-09-01).
Relational Algebra
This lecture begins by introducing Edgar Codd's work with relational data models, and his twelve rules for any relational database system. We will also review the elements of the relational data model, and introduce the operations provided by relational algebra that are at the core of a relational dabase mamagement system
Next, we will look at the relational model, and learn how to map E-R models onto relational models using simple transformations between entities/attributes and relations and their table representations.
Finally we will learn the basics of Structured Query Language (SQL) that is universally used to create and query relational databases, and how SQL operations implement the operations in relational algebra. We will also gain hands-on experience with relational algebra and SQL using the RelaX relational algebra calculator to perform query operations on example tables.
Readings
Class presentation
- Lecture 3 presentation
-
Relational algebra examples
This is a more complete version of the examples shown in class using the RelaX Relational Algebra Calculator with the "Wikipedia - Relational algebra" data set. Copy and paste individual examples into the calculator to see how each one works.
Tutorial readings
- Codd's Rules from TutorialsPoint (last accessed 2017-09-01).
- Relational Data Model from TutorialsPoint (last accessed 2017-09-01).
- Relational Algebra from TutorialsPoint (last accessed 2017-09-01).
Additional readings
- Relational algebra from Wikipedia (last accessed 2017-09-01)
- RelaX - Relational Algebra Calculator. An interactive calculator for hannds-on learning of relational algebra. (last accessed 2017-09-01)
SQL Overview
In this lecture, we will begin by introducing Structured Query Lanaguage (SQL), the language used to interact with a relational database system (RDBMS). SQL fulfills Codd's fifth rule as a comprehensive data sub-language that exclisively provides access to a RDBMS for data definition, manipulation and transactions. We will look at the major operations in SQL, what they do, and how they map into expressions in relational algebra.
Next, we will look at the topic of database design, including how to derive entity-relationship (ER) models by analyzing requirements, then how to map ER models onto a series of relationships, and finally how to transform those relationships into normalized forms to ensure that a database structure is suitable for general-purpose querying, and is free of certain undesirable characteristics including insertion, update, and deletion anomalies that could lead to loss of data integrity.
Readings
Class presentation
- Lecture 4 presentation
-
SQL examples
This is a more complete version of the examples shown in class using the RelaX Relational Algebra Calculator with the "Wikipedia - Relational algebra" data set. These correspond to the Relational Algebra examples from Lesson 3. Copy and paste individual examples into the SQL tab of the calculator to see how each one works. -
SQL Commands for Wikipedia Employee/Dept Example
This SQL file includes the commands to create the tables and insert the data for the "Wikipedia - Relational algebra" example from the RelaX Relational Algebra Calculator. Download this file, then use the Derby ij command line tool to create a database and run this SQL file to populate the database.
Additional readings
- SQL Overview from TutorialsPoint (last accessed 2017-09-01).
- SQL: Structured Query Language from TutorialsPoint (last accessed 2017-09-01).
- SQL Tutorial from w3schools.com (last accessed 2017-09-01)
- Using ij to Issue SQL Commands (last accessed 2017-09-01).
-
DUE DATE: Thu May 16 by 11:59:59pm
Use the RelaX Relational Algebra Calculator with the "Wikipedia - Relational algebra" dataset to answer these questions. Create a text file "assignment-1.txt" with your solutions in the form of a relation or a relational algebra expression that is executable in the calculator. Include a comment before each answer that identifies the question.
-
This expression uses a union of two select
operations on the Employee relation. Rewrite this as a single
select on the Employee relation with compound conditions.
(σ DeptName = 'Sales' Employee) ∪ (σ DeptName = 'Executive' Employee)
-
This expression uses select and cross join.
Rewrite it using just a single join of another kind.
σ Employee.DeptName = Dept.DeptName (Employee ⨯ Dept)
-
Is this expession an identity for the Employee or the Dept
relation (ignoring order)?
(Employee ▷ Dept) ∪ (Employee ⋉ Dept) -
Provide an expression for a relation with Employee.Name,
Employee.DeptName, and Dept.Manager attributes.
If the employee has no manager, the Dept.Manager
attribute will be NULL. Form the relation using
a specific kind of join of the Employee
and Dept relations on the DeptName attribute so
that there is a tuple even if there is no matching Dept
tuple for an Employee tuple.
- Provide an expression for a relation showing the names of employees who have a manager. Form the relation using a specific kind of join of the Employee and Dept relations on the DeptName attribute so the resulting relation has only employees that have managers. Note: a manager cannot manage his or herself.
- Provide an expression for a relation showing the names of departments that have no employees. Form the relation using a specific type of join of the Dept and Employee relations.
- Provide an expression for a relation showing the names of employees who are not managers. Hint: may require renaming an attribute.
-
DUE DATE: Mon May 20 by 11:59:59pm
Use the RelaX Relational Algebra Calculator with the "Wikipedia - Relational algebra" dataset to answer these questions. Create a text file "assignment-2.sql" with your solutions in the form of SQL statements in the SQL tab of calculator. Include a comment before each answer that identifies the question.
-
This SQL statement uses a union of two select operations on the
Employee relation. Rewrite this as a single select on the
Employee relation with compound conditions.
(select * from Employee where DeptName = 'Sales') union (select * from Employee where DeptName = 'Executive')
-
This SQL statement uses a cross join. Rewrite it using a natural join.
select * from Employee, Dept where Employee.DeptName = Dept.DeptName
- Provide a SQL statement for a relation with Employee.Name, Employee.DeptName, and Dept.Manager attributes. If the employee has no manager, the Dept.Manager attribute will be NULL. Form the relation using a specific kind of join of the Employee and Dept relations on the DeptName attribute so that there is a tuple even if there is no matching Dept tuple for an Employee tuple.
- Provide a SQL statement for a relation showing the names of employees who have a manager. Form the relation using a specific kind of join of the Employee and Dept relations on the DeptName attribute so the resulting relation has only employees that have managers. Note: a manager cannot manage his or herself.
- Provide a SQL statement for a relation showing the names of departments that have no employees. Form the relation using a specific type of operator on selections of Dept and Employee relations.
- Provide a SQL stetement for a relation showing the names of employees who have no manager. One approach is to solve it in terms of a relation showing names of employees who do have a manager.
- Provide a SQL statement for a relation showing the names of employees who are not managers.