DEV Community

Manoj Kumar
Manoj Kumar

Posted on

PostgreSQL Table Design — Constraints, Defaults, and Foreign Keys Explained Simply

This set of problems is all about designing tables the right way from the start. Not just creating columns but making the database itself enforce the rules so bad data can never sneak in. Each problem adds something new and by the end you have a solid picture of how real tables are built.


1. Students Table — Primary Key

Every student needs a unique ID. That is what PRIMARY KEY does. It makes sure no two rows have the same ID and the value can never be empty.


sql
Enter fullscreen mode Exit fullscreen mode

Top comments (0)