Chapter 11. Constraints, Views, and Transactions: Too many cooks spoil the database

image with no caption

Your database has grown, and other people need to use it. The problem is that some of them won’t be as skilled at SQL as you are. You need ways to keep them from entering the wrong data, techniques for allowing them to only see part of the data, and ways to stop them from stepping on each other when they try entering data at the same time. In this chapter we begin protecting our data from the mistakes of others. Welcome to Defensive Databases, Part 1.

Greg’s hired some help

Greg has hired two people to help him manage his growing business. Jim’s going to handle entering new clients into the database, while Frank’s in charge of matching people up to prospective jobs.

Greg has spent some time explaining his database to them and describing what each table does.

image with no caption
image with no caption

Jim’s first day: Inserting a new client

Jim’s sitting in his new cubicle and gets an IM from Greg:

image with no caption

Brain Power

Can you write the queries to insert this new person into the database?

Jim avoids a NULL

As he’s entering the data, Jim realizes that ...

Get Head First SQL 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.