Chapter 5. Building a Solid Data Model

Data modeling is an art form. Based on the previous chapter, we begin with the principle that the database is not simply a place where information is temporarily dumped but rather it is the fortress that houses and protects your company’s critical information assets. You’ve got to design the data layer so that it does its job of protecting your data.

This is accomplished in part by ensuring your schema provides for complete referential integrity and has appropriate constraint checking. Further, the data layer’s design should be one that makes future changes and additions easy. Designed incorrectly, seemingly small changes in business needs, if they require changes to the data layer, can often become Herculean efforts if the initial design is not flexible, or is crippled by inconsistencies revealed by the design change. Adhering to domain key/ normal form (DK/NF) ensures, among other things, that it is easy to add additional layers of complexity on top of your data model without the need to redesign the entire schema. As it happens, DKNF is also a necessity to get the most protection out of referential integrity checks.

Theatre Tickets

Over the course of this book, we will build a website for movie ticket sales. In this chapter, we construct a first pass at the data model. We will start simple with a very small set of tables and secure those tables with database constraints and referential integrity checks in the data layer and analogous ...

Get Enterprise Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.