Data Analyst

Case File: The Table That Allowed Anything

The payments table was created in a hurry with no rules at all, and last month somebody entered a negative amount, a payment for a customer that does not exist, and the same payment twice. In a real SQLite database in this page, rebuild the table so that the database itself refuses bad data: primary key, NOT NULL, a foreign key to customers, CHECK constraints for the amount and the method, and UNIQUE over customer, date and amount. The checks inspect the table and try to break it with bad rows. The database is generated for you alone.

55 min

Case File: The Table That Allowed Anything

The payments table was created in a hurry with no rules at all, and last month somebody entered a negative amount, a payment for a customer that does not exist, and the same payment twice. In a real SQLite database in this page, rebuild the table so that the database itself refuses bad data: primary key, NOT NULL, a foreign key to customers, CHECK constraints for the amount and the method, and UNIQUE over customer, date and amount. The checks inspect the table and try to break it with bad rows. The database is generated for you alone.

In this lesson:

  • sql
  • sqlite
  • constraints
  • primary key
  • foreign key
  • check
  • unique
  • data integrity
  • case-file

๐Ÿ”’ This lesson is part of a paid plan

This lesson is part of the Pro plan. Upgrade to unlock the full lesson, the labs and the exam.

Upgrade Now

This lesson is part of a paid plan

Upgrade to Pro to unlock this course, its labs and its exam.

View Pricing Plans