# Data Models — Database Fundamentals

Source: https://www.skillbyai.com/en/database-fundamentals/f-models

> Compare relational, document, key-value, wide-column and graph data models.

## Ways to structure data

A **data model** is a set of concepts for describing data, relationships and constraints. The **relational model**, proposed by E. F. Codd in 1970, organises data into **relations** (tables) of **tuples** (rows) with **attributes** (columns) and is queried with SQL; it dominates business systems because of its strong theory, flexible queries and transactions. Older **hierarchical** and **network** models (IMS, CODASYL) are mostly historical. **NoSQL** models emerged for scale and flexibility: **document** stores (MongoDB) keep nested JSON-like documents; **key-value** stores (Redis, DynamoDB) map keys to opaque values for very fast lookups; **wide-column** stores (Cassandra, HBase) organise data by row key and column families for massive write volumes; **graph** databases (Neo4j) store nodes and edges for highly connected data such as social networks and recommendations. Many modern relational databases also support JSON columns, blurring the lines. The **entity-relationship (ER) model** is a conceptual design model used before choosing a logical model.

## One customer in four data models

The same information shaped for different access patterns.

```text
relational:   customers(id, name)          orders(id, customer_id, total)
              (42, 'Asha')                  (1001, 42, 1499)

document:     { "_id": 42, "name": "Asha",
                "orders": [ { "id": 1001, "total": 1499 } ] }

key-value:    "customer:42" -> '{"name":"Asha"}'

graph:        (Asha:Customer)-[:PLACED]->(o1001:Order {total: 1499})
              (Asha)-[:FRIEND_OF]->(Ravi:Customer)
```

## Choose by access patterns

Relational is a safe default for most applications. Pick another model when a specific access pattern dominates: huge key lookups, deeply connected traversals, or flexible nested documents read as a unit.

**Quiz:** Who proposed the relational model of data, and when?

- [ ] Larry Ellison, 1979
- [ ] Peter Chen, 1990
- [x] E. F. Codd, 1970
- [ ] Edgar Dijkstra, 1965

*Answer:* E. F. Codd, 1970. Codd described the relational model in his 1970 paper at IBM.
