Example Database
I illustrate most of the topics in SQL Antipatterns using a database for a hypothetical bug-tracking application. The entity-relationship diagram for this database is shown in Figure 2, Diagram for example bug database. Notice the three connections between the Bugs table and the Accounts table, representing three separate foreign keys.
The following data definition language shows how I define the tables. In some cases, choices are made for the sake of examples later in the book, so they might not always be the choices one would make in a real-world application. I try to use only standard SQL so the example is applicable to any brand of database, but some MySQL data types also appear, such as SERIAL and BIGINT.
| Introduction/setup.sql ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access