Skip to content

Informatics Practices · Ch 6 — Database Concepts

Key Concepts in DBMS

6.3.2

Key Concepts in DBMS

Managing data efficiently with a DBMS requires a small vocabulary of core ideas. Each term below answers a different question about a database: what is its design (schema), what data is allowed in (constraints), where the design itself is stored (meta-data), what the data looks like at a moment in time (instance), how we ask for data (query), how we change data (data manipulation), and what actually does the work underneath (database engine).

(A) Database Schema

The database schema is the design of a database — its skeleton. It represents:

  • the structure: table names and their fields (columns),
  • the type of data each column can hold,
  • any constraints on the data to be stored, and
  • the relationships among the tables.

Because the schema tells us how the data are organised in the database, it is also called the visual or logical architecture of the database.

Figure 7.3 pictures the StudentAttendance database environment built on this idea: multiple users (the teacher, the office staff) send queries; the DBMS software processes each query, accesses the database and its definition (the database catalog), and returns the query result. The three tables — Student, Guardian and Attendance — sit inside one database that everyone shares.

(B) Data Constraint

Sometimes we deliberately put restrictions or limitations on the type of data that can be inserted into one or more columns of a table. These restrictions, specified while creating the table, are called constraints.

Examples:

  • A mobile-number column can be constrained to accept only non-negative integer values of exactly 10 digits.
  • Since every student must have one unique roll number, the RollNumber column can carry the NOT NULL constraint (a value must be present) and the UNIQUE constraint (no two rows may share a value).

Constraints exist to ensure the accuracy and reliability of the data in the database — bad values are rejected at the door instead of being discovered later.

(C) Meta-data or Data Dictionary

The database schema, along with the various constraints on the data, is stored by the DBMS in a database catalog (also called the data dictionary). This stored description is the meta-data — literally, data about the data. When the DBMS processes a query, it consults this catalog to know what tables exist, what columns they have, and what rules apply.

(D) Database Instance

When the database structure (schema) is first defined, the database is empty — there is no data in it yet. After data is loaded, the state or snapshot of the database at any given time is called the database instance.

From then on, data can be retrieved through queries or changed through updation, modification or deletion — so the state of the database keeps changing. This gives an important distinction:

Important

The schema is fixed at design time, but the data keeps changing — so one database schema can have many different instances at different times. The schema is the skeleton; an instance is a photograph of the body at one moment.

(E) Query

A query is a request made to the database for obtaining information in a desired way. A query may pull data from a single table or from a combination of tables. For example, "find the names of all those students present on Attendance Date 2000-01-02" is a query to the StudentAttendance database — answering it needs both the ATTENDANCE table (who was present) and the STUDENT table (their names).

To retrieve or manipulate data, the user writes queries in a query language; this language is taken up in detail in the next chapter (Chapter 8).

(F) Data Manipulation

Modification of a database consists of three operations — Insertion, Deletion and Update:

  • Insertion — when Rivaan joins as a new student in the class, his details must be added to the STUDENT table, and his guardian's details to the GUARDIAN table, of the Student Attendance database.
  • Deletion — when a student leaves the school, his or her data and the corresponding guardian details must be removed from STUDENT, GUARDIAN and ATTENDANCE respectively.
  • Update — when Atharv's guardian changes his mobile number, the GPhone value in the GUARDIAN table must be updated.

(G) Database Engine …

Figure 7.3StudentAttendance Database Environment

The figure depicts the working environment of the StudentAttendance database — who uses it, what stands between the users and the stored data, and how a request travels through the system. At the top sit the two kinds of users from the school example: a Teacher at a desk on the left and a group of Office Staff at a desk on the right. From each of them, an arrow labelled "Query" points downward into a large rounded grey region that represents the DBMS environment.

Inside that region, two stacked banner bars name the software's jobs: "DBMS Software processes Query" and "DBMS Software access database and its definition". Below the banners, double-headed vertical arrows connect the software to two groups of storage cylinders. On the left stands a stack of three cylinders labelled Student, Guardian and Attendance — the actual data of the database. On the right is a single cylinder labelled Database Catalog — the database's definition, i.e. its schema and constraints stored as meta-data. A horizontal double-headed arrow links the three-cylinder stack to the Database Catalog, showing that the data and its description belong together. Finally, two large curved arrows labelled "Query Result" sweep up the outer edges of the region, carrying answers back to the Teacher on the left and the Office Staff on the right. …