Database Systems Fundamentals


Database Systems Fundamentals

Corey
Welcome to the database systems course. Before we get into the technical details, let’s map out the journey. The course is organized into roughly eight modules, with several lectures in each module, and the plan is to avoid starting a new module partway through a lecture.

Anna
And the central theme is relational databases. The modules include an introduction, the relational model, the entity-relationship model, tuple relational calculus, and SQL, which is the database language standard. We’ll also cover file systems and the physical representation of databases, database design and normal forms, query optimization, and finally transaction processing and error recovery.

Corey
That gives us a useful arc: first, how to describe data and ask questions about it; then how to store it, design it well, retrieve it efficiently, and protect it when things go wrong.

Anna
So let’s begin with the basic question: what is a database? It’s a collection of related pieces of data that capture information about some real-world enterprise, or part of one. The word “related” matters: a university database about academic activity wouldn’t normally include unrelated weather data.

Corey
And an enterprise can be large enough that one database doesn’t capture all of its information. A database is built for a particular purpose: to meet some of the enterprise’s data-management needs and support its day-to-day activities.

Anna
The database also changes as the enterprise changes. If something happens in the organization that affects the information it tracks, the database needs to be updated so it continues to reflect the current state of affairs.

Corey
Take a university database focused on academic matters. It might keep information about students and faculty, the courses offered, research laboratories, and which students enroll in which courses. Its purpose would be to accurately track the university’s academic activities, not necessarily every aspect of the institution.

Anna
Now let’s separate two ideas that are easy to blur together: a database and a database management system, or DBMS. The database is the collection of related data. In principle, someone could keep that information in paper ledgers; the DBMS is the software used to create and manage databases on computer systems.

Corey
A DBMS is general-purpose software that helps create large databases stored on disk. Disk storage matters because a database is meant to preserve information over time. Main memory is volatile, so its contents can disappear when an application closes or the system loses power.

Anna
Disks can fail too, and the course will return to that problem later. But secondary storage is still the mainstay for databases because persistent information must remain available beyond the lifetime of a running program.

Corey
A DBMS also lets users ask questions of the stored data. Suppose you want to know whether a student in a particular semester completed a particular course. You express that need as a query, and the system returns information from the database.

Anna
SQL provides a standard way to express many database queries. It’s more than a language used by one product: it is an internationally recognized standard for describing database operations and requests. The DBMS supports that standard and works to produce query results efficiently.

Corey
Efficiency becomes important when the database is large. Finding one particular fact among a great deal of stored information can take time, so the DBMS has to process queries in a way that aims to return the answer as quickly as possible.

Anna
Another major challenge is that many people may use the same database at once. A system that handled only one person’s request at a time would be inefficient, so a DBMS supports concurrent use: many users can make requests while each experiences the system as responding to their own question.

Corey
But answering many requests concurrently isn’t enough. The system also has to preserve consistency, and the exact consistency requirement depends on the application.

Anna
A railway reservation system makes that concrete. If several people request seats between the same two stations at nearly the same time, the system must not assign one particular seat to two different people. That rule is a consistency requirement for that application.

Corey
So consistency isn’t one identical rule for every database. It depends on what the data represents and what the organization needs to guarantee. The DBMS has to manage concurrent requests without violating those application-specific requirements.

Anna
The system also needs to make data available despite failures. One kind of failure is damage to the storage medium itself. A disk can fail, but an organization can’t simply accept that its data is lost.

Corey
For serious disasters, one possible measure is to replicate an entire database at a geographically separate location. If a fire, storm, or other catastrophic event destroys the physical server in one place, a copy elsewhere can help keep the data available.

Anna
There are also failures during the work being done on the database. A program might crash partway through a change. If only part of its work has taken effect, the database could be left in an inconsistent state.

Corey
The system therefore needs to handle incomplete operations so that partial changes don’t undermine consistency. Transaction processing and recovery will examine these issues in much more detail later in the course.

Anna
At this point, you might ask why we need special database software at all. Programmers can create files of records using languages such as C or C++, and operating systems already provide file handling. Why not write programs to manage everything ourselves?

Corey
One difficulty is redundant data. Imagine one application tracking students’ courses and grades, and another tracking their health records for a university hospital. Both might store a student’s name, phone number, and address.

Anna
Storing a fact in two places isn’t necessarily a problem just because it takes up space. The harder problem is keeping the copies consistent. If a student changes their phone number, each copy must be updated; otherwise, one part of the organization may have the old number while another has the new one.

Corey
With separate, independently written programs, coordinating those updates becomes difficult. Changes have to be communicated and applied everywhere the data appears. That creates opportunities for inconsistent information.

Anna
Another problem is that record structures tend to be hard-coded into programs. In a typical program, you define a structure before creating and using records of that type. If the structure changes, the software may need to be changed and recompiled.

Corey
That makes even a modest change in how information is organized burdensome. A DBMS addresses this by separating descriptions of the data from the programs that work with it, which gives more flexibility when the structure changes.

Anna
Handling queries by writing a separate program for each possible question is another problem. Each program would need to search through the records in its own way, and it’s hard to anticipate every question an end user might ask in advance.

Corey
And the burden wouldn’t stop there. Programmers would also have to manage concurrent access and recover from failures themselves. Those are difficult tasks, especially when many users and large amounts of data are involved.

Anna
That’s why building a database system out of a collection of custom file-processing programs requires enormous effort and is very difficult to scale to the needs of a real database. A DBMS provides the shared capabilities instead of making every application reinvent them.

Corey
One key DBMS idea is separating data from metadata. Metadata is information that describes the data, including how records are structured. Rather than embedding all of those descriptions inside each application, the DBMS maintains them separately in a system catalog.

Anna
A program can consult the catalog to find out how information is stored, then operate on the data according to that description. Because the description is separate, changing the metadata doesn’t necessarily mean rewriting every program that uses the data.

Corey
That separation is called program-data independence. The programs are, in an important sense, less tightly bound to the details of the data’s structure. If the structure changes, the catalog can be updated, and programs can use the revised description.

Anna
It also helps explain why a DBMS is general-purpose. One DBMS can manage different databases—for example, hospital records, staff accounts and salaries, and students’ academic records—while each database has its own descriptive information in the catalog.

Corey
The standard query language is another part of the benefit. Relational database theory gives us a foundation for expressing queries, and SQL gives users a widely recognized way to state their data needs.

Anna
Under the hood, the course will study ideas such as tuple relational calculus and relational algebra. The point is that these formal approaches help describe what kinds of queries can be expressed; once a DBMS implements the language’s constructs, users can formulate many different queries without requiring a special program for each one.

Corey
That changes the work of designing a system, too. For a university academic database, designers can talk with the academic section to learn what information it needs to track and what queries it routinely needs.

Anna
Then they can focus on the logical design: what information should be represented and how it should be organized. The DBMS takes care of much of the underlying storage organization, query processing, and management of concurrent users.

Corey
So the designers still have important choices to make. They need to understand the enterprise and its data, and identify the useful day-to-day queries. But they don’t have to build every storage and processing mechanism from scratch.

Anna
There are many available DBMS products. Examples mentioned in the course include Oracle, IBM’s DB2, and Microsoft SQL Server. The broader lesson is that database management systems are now a standard tool, even if it’s easy to take their capabilities for granted.

Corey
That brings us to a new concept: the data model. A data model is a collection of conceptual tools for describing a database at a particular level of abstraction.

Anna
Why do we need different levels? Because people need to discuss a database for different purposes. When gathering requirements, we need a clear, high-level picture. When designing its logical organization, we need more detail. And when implementing it, we need to specify the physical storage.

Corey
At the conceptual level, the description is high-level and useful for understanding requirements. Database designers can use it to discuss with people who know the organization’s needs, even if those people aren’t computer scientists.

Anna
The entity-relationship model is one popular conceptual data model, and it will receive its own module. It uses the ideas of entities, relationships, and attributes—concepts that can be explained and discussed with nontechnical stakeholders.

Corey
In the university example, entities might include students, faculty members, courses, and departments. A relationship might represent students enrolling in courses, or faculty members being employed by departments.

Anna
Attributes describe details associated with those entities. A student, for instance, might have a name, a role number that distinguishes them from other students, and an address. These are the kinds of details designers can identify while gathering requirements.

Corey
A representational data model describes the database at a logical level, while setting aside many details of physical storage. That helps designers concentrate on how data is represented logically, rather than on the files and record formats that will eventually hold it.

Anna
That distinction matters because a poor logical design can cause problems even before we consider physical implementation. A representational model gives us a way to focus on the design itself without getting distracted by lower-level storage details.

Corey
At the physical level, we describe those details directly: record formats, files, and the external data structures used to represent and organize the database. This is where we specify how the information is actually represented in storage.

Anna
So the levels build on one another: conceptual tools help us understand and communicate requirements; representational tools help us design the logical organization; and physical models describe the implementation details.

Corey
And that’s the foundation for the course: what databases are, what a DBMS contributes, why dependable and consistent management matters, and how data models let us describe a database at different levels. With those ideas in place, we’re ready to study the relational model and the other modules in more depth.

Ask anything
We've read this whole study set, so questions about it get the best answers.