PostgreSQL: constraints, data types and privileges
Mama Ngo is back from the village. While she was away, her niece Nadia ran the till for a whole week. "There are sales at zero, a payment method nobody knows, and the rice twice. Couldn't the machine refuse on its own?" In the previous workshop, you learnt to write carefully. But care only protects what you type yourself. The only protection that works for everyone is the database that refuses. You start by finding the damage with the queries you know, then you try to set the rule that would have prevented it, and the database refuses to create it: existing rows already violate it. That refusal becomes your clean-up plan. You clean up without losing anything, after asking Nadia what really happened, because strange data is not necessarily wrong. Then you set the rules the database will enforce on everyone: CHECK, UNIQUE, DEFAULT. You merge the duplicated rice despite the foreign key standing in the way, you choose the type of each piece of information on a delivery note, and you create the deliveries table, with its automatic numbering and its link to the products. Finally, you discover that a new table is closed to everyone, and you grant the right to read it, and only to read it. Everything happens in the terminal, with the database owner's account. At the end, the rules you set and the table you created are checked in the database, and the result counts for your ranking.
- No reviews yet
- Intermediate
- 2 h
- 750 credits
- First lab free