Relational Databases & SQL
Relational databases store data in tables with rows and columns. Every table has a primary key that uniquely identifies each row, and foreign keys that express relationships between tables. SQL is the language you use to create, read, update, and delete that data.
The power of relational databases comes from JOINs — combining rows from multiple tables based on a shared key. A well-designed schema with normalized tables and proper foreign keys prevents duplicated data and maintains consistency. PostgreSQL, MySQL, and SQL Server all speak standard SQL with minor dialects.
Security boundary: never concatenate user input into SQL. Use parameterized queries or a trusted query builder, and grant the app database role least privilege (no DROP/ALTER in production app roles).
Exercise
Write one JOIN that returns order id, total, and customer email for a given user_id. Then rewrite the same need as two queries and note when the JOIN is preferable. Use parameterized placeholders ($1 / ?) — never string-concatenate user input.