Information Technology · Ch 3 — Relational Database Management System - II
Recap and the Sample Tables Used in This Chapter
Recap and the Sample Tables Used in This Chapter
In the first-year Information Technology course you learned the foundations of a Relational Database Management System (RDBMS) and the basics of MySQL — how data is stored in tables (relations) made of rows (tuples) and columns (attributes), how to create a database and tables with DDL, how to insert, update, delete and read data with DML, and how to filter rows with a WHERE clause. This second-year chapter takes those foundations further. It shows how MySQL keeps data safe during a group of changes using transactions (COMMIT and ROLLBACK), how missing values (NULL) are handled, how to summarise data using aggregate functions and GROUP BY, how MySQL's built-in string, mathematical and date-time functions work, and finally how data from more than one table can be brought together using the cartesian product, equi-join and UNION.
MySQL is a popular, open-source RDBMS (free to download and use), operated with SQL (Structured Query Language). As before, SQL keywords are written in capitals by convention and every statement ends with a semicolon (;). Because Odisha's +2 Information Technology syllabus draws on the same standard, well-established database principles used throughout computing, everything you learn here applies directly to any relational database system you meet later.
Throughout the chapter we will work with two small sample tables so that every example refers to real data you can picture. The first is an Employee table:
| EmpNo | Name | Dept | Salary | JoinDate |
|---|---|---|---|---|
| 101 | Aarti Behera | Sales | 25000.00 | 2022-06-01 |
| 102 | Rohan Das | Sales | 30000.00 | 2021-03-15 |
| 103 | Sneha Mohanty | Accounts | 28000.00 | 2023-01-10 |
| 104 | Pratik Sahoo | Accounts | 32000.00 | 2020-11-20 |
| 105 | Manoj Nayak | IT | 40000.00 | 2019-07-05 |
| 106 | Ipsita Rout | IT | NULL | 2024-02-01 |
Here EmpNo is the primary key, Salary is a DECIMAL money value (note that employee 106's salary is NULL — not yet fixed), and JoinDate is a DATE. The second table, Dept, lists each department and the city it operates from:
| DeptName | City |
|---|---|
| Sales | Cuttack |
| Accounts | Bhubaneswar |
| IT | Bhubaneswar |
The two tables are related: the Dept column of Employee matches the DeptName column of Dept. That shared value is what will let us join the two tables later in the chapter. For reference, the Employee table could be created and filled like this:
CREATE TABLE Employee (
EmpNo INT PRIMARY KEY,
Name VARCHAR(50),
Dept VARCHAR(20),
Salary DECIMAL(10, 2),
JoinDate DATE
);
With these two tables in mind, we can now study each new topic in turn.
A Relational Database Management System — software that stores and manages data as related tables of rows (tuples) and columns (attributes) and is operated using SQL; MySQL is the open-source RDBMS used in this course.
The two related tables used throughout this chapter: Employee(EmpNo, Name, Dept, Salary, JoinDate) with EmpNo as primary key, and Dept(DeptName, City). The Employee.Dept value matches Dept.DeptName, which lets the tables be joined.