A relational database stores data in related tables with a predefined schema, while a NoSQL database can use non-tabular models with flexible structures. Relational databases prioritize structured relationships and consistency; NoSQL databases often prioritize flexibility and horizontal scalability.
How the Database Models Differ
A relational database represents data as rows and columns. A primary key uniquely identifies each record; a foreign key links records across tables. Structured Query Language (SQL) accesses data, while normalization reduces unnecessary duplication.
NoSQL means “not only SQL.” Its models include document, key-value, graph, and wide-column databases. They may store related information together instead of splitting it among normalized tables.
| Feature | Relational database | NoSQL database |
|---|---|---|
| Data model | Tables with rows and columns | Documents, key-value pairs, graphs, or wide columns |
| Schema | Usually predefined and rigid | Often flexible and easier to change |
| Relationships | Primary and foreign keys | Embedded links or graph edges |
| Scaling | Often vertical: improve one server | Often horizontal: distribute across servers |
| Transactions | Typically strong ACID transactions | Support varies by system |
| Best suited to | Structured data with stable relationships | Changing, distributed, or semi-structured data |
For example, a school could store students and classes in separate relational tables connected by IDs. A document database could store each student as one document with an embedded class list. This reduces joins but may duplicate data.
A common misconception is that NoSQL databases cannot use schemas or transactions. They can support both; their structures and consistency models are often more flexible than those of traditional relational systems.
IB Exam Technique
For A3.4 Alternative databases and data warehouses (HL only), compare models using named criteria rather than only defining them. Apply the choice to the scenario: relational databases suit stable, highly related data requiring transaction integrity; NoSQL may suit rapidly changing or distributed applications needing flexible scaling.