Database Models (Supplemental)
Purpose
This supplemental reading gives conceptual background on relational and NoSQL systems. The required implementation work remains in Database Connectivity.
Relational vs NoSQL
- Relational databases store data in structured tables with relationships between rows. You query with SQL and enforce constraints such as primary keys and foreign keys.
- NoSQL databases prioritize flexible document or key-value structures and can be easier when data shape changes frequently.
Why This Activity Uses PostgreSQL
For the portfolio project data in this course, PostgreSQL is a strong default because:
- The data is structured and predictable (id, title, description, type, technologies, link).
- We benefit from reliable constraints and typed columns.
- SQL queries are straightforward for filtering and future reporting.
- PostgreSQL can still store flexible values (for example arrays and JSON) when needed.
When MongoDB Can Be a Better Fit
MongoDB can be a better choice when:
- Records have highly variable fields from one document to another.
- You need rapid iteration on data shape without frequent schema migrations.
- Your system is primarily document-centric rather than relationship-centric.
Quick Comparison
| Dimension | PostgreSQL | MongoDB |
|---|---|---|
| Data Model | Tables, rows, relationships | Documents (JSON-like) |
| Schema | Defined and enforced | Flexible, often evolving |
| Best For | Relational consistency and SQL queries | Rapidly changing document structures |