| Lesson 3 |
The course project |
| Objective |
Create pages that access and manipulate a database. |
Database Web Course Project
For the duration of this course, imagine yourself as a web application developer for a company called VirtualBookShelf.
VirtualBookShelf is an online bookstore, and you are the developer building the pages that access and manipulate its database. This is the course project referenced in Lesson 2: one continuous application, built up module by module, using the same stack the lessons themselves teach, Visual Studio 2026, ASP.NET Core Razor Pages on .NET 10, C#, ADO.NET and later Entity Framework Core, against SQL Server 2025.
The database has three tables:
- Customer. Will be enhanced as the course progresses.
- Inventory. Will be enhanced as the course progresses.
- A sales transactions table. It exists in the database, but you will not be using it in this course.
A bookstore's inventory and customer list is a deliberately familiar kind of data. Everyone understands what a book is, what a customer record needs to hold, and what it means to look one up, add one, change one, or remove one. That familiarity is the point: the goal of this project isn't to teach you about bookstores, it's to give you one small, well-understood domain to practice the CRUD operations (Create, Read, Update, Delete) that Lesson 1 introduced, without the domain itself getting in the way of the SQL Server and ASP.NET Core concepts you're actually here to learn.
This is also why the project stays deliberately small rather than trying to model a full, realistic bookstore. A real online bookstore's database would include publishers, categories, multiple warehouses, shipping addresses, discount codes, and a dozen other tables before it could handle real orders. None of that teaches you anything new about Razor Pages, ADO.NET, or SQL Server that two well-designed tables can't teach just as well, and all of it would add complexity that has nothing to do with this course's actual subject. VirtualBookShelf is a learning project, not a product; it's sized to let every module add one clear, visible capability to something you can run and look at, not to be a template for a commercial application.
The Starting Schema
Neither table exists yet on your own machine; building them is part of this project. The starting point below is intentionally minimal, enough columns to support the queries and pages this course builds early on, with obvious room for the kind of enhancements later modules will add.
Customer
CREATE TABLE Customer (
CustomerID INT IDENTITY(1,1) PRIMARY KEY,
FirstName NVARCHAR(50) NOT NULL,
LastName NVARCHAR(50) NOT NULL,
Email NVARCHAR(100) NOT NULL,
Phone NVARCHAR(20) NULL,
DateJoined DATE NOT NULL DEFAULT GETDATE()
);
Inventory
CREATE TABLE Inventory (
BookID INT IDENTITY(1,1) PRIMARY KEY,
Title NVARCHAR(200) NOT NULL,
Author NVARCHAR(100) NOT NULL,
ISBN NVARCHAR(20) NULL,
Price DECIMAL(10,2) NOT NULL,
QuantityOnHand INT NOT NULL DEFAULT 0
);
A few of these choices are worth explaining rather than just listing.
CustomerID and
BookID are both
IDENTITY(1,1) columns, meaning SQL Server assigns each new row its primary key value automatically, starting at 1 and incrementing by 1, so your Razor Pages never need to generate an ID themselves.
Price uses
DECIMAL(10,2) rather than a floating-point type, because money values need to add and compare exactly, and floating-point arithmetic can introduce small rounding errors that a decimal type avoids entirely.
Email and
Phone are left as plain
NVARCHAR columns for now; later modules on data validation will have more to say about enforcing their format.
Phone is nullable, since not every customer record needs one, while
Email is not, since this project's later lessons on user accounts will depend on every customer having one.
If you already have a background in database design, or if a later lesson introduces a column this starting schema doesn't anticipate, treat this as a floor rather than a ceiling. The two statements above are meant to get a working table under you quickly, not to represent the final word on what a bookstore's schema should look like.
A handful of sample rows makes the schema concrete before you've written a single query against it. A few rows in Customer might look like this once populated:
| CustomerID | FirstName | LastName | Email | Phone | DateJoined |
| 1 | Maria | Alvarez | maria.alvarez@example.com | 555-0114 | 2026-01-08 |
| 2 | David | Chen | dchen@example.com | NULL | 2026-02-22 |
And a few rows in Inventory:
| BookID | Title | Author | ISBN | Price | QuantityOnHand |
| 1 | The Pragmatic Programmer | David Thomas | 9780135957059 | 44.99 | 12 |
| 2 | Clean Code | Robert C. Martin | 9780132350884 | 39.99 | 7 |
Notice that David Chen's
Phone value is
NULL, which the schema above allows and
Email does not; that single difference between the two columns is a small, concrete first example of a constraint actually mattering, rather than just being a rule stated in the abstract.
One more detail worth noticing in these sample rows:
ISBN is stored as
NVARCHAR(20) rather than as a number, even though an ISBN is a sequence of digits. ISBNs can include a leading zero that a numeric type would silently drop, and some older ten-digit ISBNs end in the letter
X rather than a digit, which a numeric column couldn't store at all. A value that looks numeric isn't automatically a candidate for a numeric column; what matters is whether you'll ever do arithmetic on it, and nobody adds, subtracts, or averages ISBNs.
What "Enhanced" Actually Means
Lesson 1 described this course's module order: SQL fundamentals and CRUD, a first Razor Pages application, data entry pages through ADO.NET, more advanced SQL covering joins, computed columns, stored procedures, and indexing, and finally Entity Framework Core. Each of those modules has a natural place to touch the Customer and Inventory tables above:
| Module Topic | How It Touches This Schema |
| SQL fundamentals and CRUD | Writing the INSERT, SELECT, UPDATE, and DELETE statements this project's pages will eventually call |
| A first Razor Pages application | A page that lists Inventory, reading rows and rendering them as HTML |
| Data entry through ADO.NET | Pages that add a new Customer or adjust an Inventory row's QuantityOnHand |
| Joins and computed columns | Once a connection exists between Customer activity and Inventory, a joined query or a computed column summarizing it |
| Stored procedures | Moving a frequently used operation, such as adjusting stock after a sale, into a procedure the application calls rather than inline SQL |
| Indexing | Adding an index once Inventory has enough rows that searching by Title or Author is worth speeding up |
| Entity Framework Core | Mapping both tables to C# classes and rebuilding the same pages using EF Core instead of hand-written ADO.NET |
None of this needs to make full sense yet. The point of laying it out now is so that when a later lesson says "add a computed column to Inventory," it reads as the next planned step in something you already understand, rather than an unexplained new requirement showing up out of nowhere.
It's also worth noticing the shape of that progression: each module doesn't replace what the previous one built, it adds to it. The SQL you write directly in an early module doesn't become wasted effort once stored procedures are introduced; it becomes the body of the procedure. The ADO.NET code you write before Entity Framework Core doesn't get thrown away either; understanding what it does is what makes EF Core's generated SQL legible rather than a black box, the same point Lesson 1 made about learning ADO.NET first. By the time this project reaches its final module, you won't have rebuilt VirtualBookShelf five separate times in five separate technologies; you'll have the same two tables and a steadily growing set of pages and logic sitting on top of them.
A Preview of the Project's Shape
Without installing anything yet, here is roughly what the VirtualBookShelf Razor Pages project's folder structure will look like once the first few modules are underway:
VirtualBookShelf/
Pages/
Inventory/
Index.cshtml (lists all books)
Create.cshtml (adds a new book)
Edit.cshtml (updates price or quantity)
Customer/
Index.cshtml (lists all customers)
Create.cshtml (registers a new customer)
Data/
VirtualBookShelfContext.cs (added once EF Core is introduced)
appsettings.json (holds the SQL Server connection string)
Program.cs
Each `.cshtml` file pairs with its own `.cshtml.cs` code-behind file, following the Razor Pages convention Lesson 1 introduced: markup in one file, the C# that fetches or saves data in the other, both named after the same page. Nothing here needs to be built today. The point of showing it now is so that when the setup module asks you to create a new ASP.NET Core Razor Pages project in Visual Studio 2026, you already have a rough map of where things are headed, rather than an empty template with no sense of what will eventually fill it.
Why the Transactions Table Is Off Limits for Now
The database includes a third table that tracks sales transactions, and the legacy version of this course excluded it from the project for a reason worth stating plainly: a transactions table depends on both Customer and Inventory already existing and being populated with real data, and it introduces its own complications, a transaction references a specific customer and a specific book, needs a quantity and a price at the time of sale, and raises questions about what happens when stock runs out mid-transaction. None of that is wrong to eventually learn, it's simply more than this course's scope covers. Keeping it out of reach here isn't a limitation of the stack or the schema; it's a deliberate choice to keep the project's two active tables manageable while you're still building up the SQL and Razor Pages skills the rest of the course teaches.
If you're curious where that kind of logic would eventually live, it's worth knowing the shape of the answer even without building it: a transaction typically needs to happen as a single atomic unit, reduce QuantityOnHand on the Inventory row being sold, insert a new transaction record, and do both together or neither at all if something fails partway through. SQL Server's own transaction support, BEGIN TRANSACTION, COMMIT, and ROLLBACK, exists exactly for cases like this. It's a reasonable thing to explore after this course, once Customer and Inventory are both solid, rather than something to attempt alongside them.
Putting the Stack to Work
This lesson's stated objective, creating pages that access and manipulate a database, is really three smaller objectives stacked on top of each other, and Lesson 1 already named the technology for each layer:
- Accessing the database means ADO.NET first: opening a connection to your SQL Server 2025 instance using a connection string, building a
SqlCommand with explicit SQL text, and reading the results back through a SqlDataReader. For the Inventory list page sketched above, that means a command running something close to SELECT BookID, Title, Author, Price, QuantityOnHand FROM Inventory ORDER BY Title;, with the results read row by row and handed to the page to display. Entity Framework Core arrives later in the course once this layer is familiar, at which point the same query becomes a line of C# working against a DbSet<Book> instead of a hand-written string of SQL.
- Displaying and collecting data means Razor Pages: a page that lists Inventory rows, a form that adds a new Customer, each living in its own
.cshtml file paired with a C# code-behind file, the same page-at-a-time model Lesson 1 compared against Classic ASP. The code-behind file's OnGet method is where that ADO.NET query above actually runs; the .cshtml markup is only responsible for turning whatever that method hands back into HTML.
- Manipulating the data itself means the SQL statements this course's SQL-focused modules teach, run either directly or, once stored procedures are introduced, through a named procedure the application calls instead. A page that adjusts
QuantityOnHand after a sale, for instance, is a straightforward UPDATE statement early in the course and a call to a stored procedure, perhaps something named AdjustInventoryQuantity, once that module is reached.
Visual Studio 2026 is where all three of these come together: a single solution can hold the Razor Pages project itself alongside a reference to your SQL Server 2025 database, so you can run a page, see it query live data, and adjust either side without switching tools constantly. SQL Server Management Studio or Azure Data Studio, mentioned in Lesson 2's resource list, stay useful even once the application itself is running, since inspecting the Customer and Inventory tables directly is often the fastest way to confirm whether a bug lives in your C# code or in the data it's reading.
Common Questions About the Project
Can I change the starting schema if I think of a better design? Yes. The Customer and Inventory definitions above are a floor, not a requirement handed down from the course itself. If you add a column, rename one, or split a table differently, the lessons ahead will still make sense as long as both tables still exist in some recognizable form; just be prepared to adjust the exact SQL shown in later lessons to match whatever you changed.
Do I need to add more tables beyond the three described here? Not for this course. A fuller bookstore application would eventually need more, categories, publishers, order history, but adding them isn't required to complete any lesson in this course, and doing so before you've worked through the modules that explain joins and relationships properly tends to create more confusion than it resolves.
Does the project need to be deployed anywhere, or is it fine running locally? This course's lessons assume a local SQL Server 2025 instance and a Razor Pages application running locally through Visual Studio 2026. Deployment, to Azure or anywhere else, is a reasonable thing to explore afterward, but it isn't part of what any lesson in this course asks you to do.
What happens to the transactions table if I never touch it? Nothing. It can sit in the database unused for the entire course without causing any problem for the Customer or Inventory work described here. It's there for context, and as a natural next step if you want to extend the project later, not as a hidden requirement.
What's Ahead
This closes out Module 1. The next module moves from description to setup: installing Visual Studio 2026, confirming the .NET 10 SDK is available, and getting a SQL Server 2025 instance running where you can actually create the Customer and Inventory tables above. Once that's done, the first SQL lessons give you the fundamentals needed to populate those tables and query them back, and the project described in this lesson stops being a description and becomes something you're actually building, one module at a time.
It's worth taking stock of what this first module has actually covered before moving into setup. Lesson 1 established the stack and explained why each piece was chosen over its available alternatives. Lesson 2 covered the resources, the glossary and its vocabulary, available to support the modules ahead. This lesson has given that stack somewhere to point: a specific project, a specific starting schema, and a rough map of how each later module will extend it. None of that required installing anything or writing a line of code yet, which is exactly the point of a module like this one. By the time the next lesson asks you to open Visual Studio 2026 for the first time, you'll already know what you're building toward, rather than discovering it piecemeal as each new lesson arrives.
