Database systems · Chapter 2 · Data models
Before the relational model, two designs dominated. One is shaped like a tree, the other like a graph, and the difference between them comes down to a single rule: how many parents a record is allowed to have.
A tree. Every record sits on exactly one path down from a single root, and that path is the only way to reach it.
IBM's Information Management System, first shipped in 1966, is the model most people mean when they say hierarchical. Data is organized into segments, and segments are joined by parent and child links. The topmost segment is the root. To read anything, a program starts at the root and walks down a branch, one segment at a time.
The rule that defines the model is simple: a child segment has one and only one parent. A parent segment may have many children, so one to many relationships are natural, and because the path to any record is fixed and short, retrieval along that path is fast.
Professor Lee teaches a statistics course in Mathematics and a mechanics course in Physics. Because a segment can have only one parent, there is no single place to store her record. She is written once under each department, and the two copies now have to be kept in agreement by hand. This is the redundancy problem the relational model exists to solve.
A graph. A record can belong to more than one owner, so the same record can sit on several paths at once.
The network model was formalized by the Conference on Data Systems Languages, through its Data Base Task Group, in a report published around 1971. It built on Charles Bachman's earlier Integrated Data Store, and it is also where the terms schema, subschema, and a separate data definition language and data manipulation language entered common use, terms the relational world later kept.
Data is still stored in records, but relationships are stored as sets. A set has one owner record type and one or more member record types, and one set occurrence is one owner together with all of the members that belong to it. The rule that defines the model is the opposite of the hierarchical one: a member record can take part in more than one set, so it can have more than one owner, and a record can be an owner in one set while being a member in another.
To connect students and courses many to many, the design adds one ENROLLMENT record for each registration and makes it a member of two sets: one owned by STUDENT, one owned by COURSE. No student record is copied, no course record is copied, and Professor Lee's earlier problem never comes up, because COURSE can be owned by more than one path into the graph as well.
The cost is complexity. A network schema can grow into a genuine web of sets, and a program still has to navigate it one pointer at a time, entering a set at its owner and stepping through its members. Changing the set structure usually means rewriting the code that walks it, which is the same structural dependence the hierarchical model has, just spread across a richer shape.
Same questions, two different answers.
| Question | Hierarchical | Network |
|---|---|---|
| Overall shape | An inverted tree | A graph, sometimes called a plex |
| Parents per record | Exactly one | One or many |
| Building blocks | Segments joined by parent and child links | Records joined by sets with one owner and one or more members |
| One to many | Native | Native |
| Many to many | Only by duplicating data across two paths | Native, through a record that is a member of two sets |
| Best known system | IBM Information Management System, 1966 | The CODASYL Data Base Task Group standard, around 1971 |
| How you read it | Start at the root, walk down one branch | Start at any owner, walk into its set |
Two ideas the earlier models shared turned out to be the ones worth giving up.
Both models are navigational. A query is a sequence of steps through stored pointers, and that sequence has to be written into the application. The relational model is declarative instead: a query states what result is wanted, and the system works out how to get it, which means the same request can be satisfied no matter how the data happens to be laid out underneath.
Both models also carry structural dependence. If a tree grows a new branch or a set gets a new member type, every program that walked the old structure may need to change. A relational query written against a primary key and a foreign key does not know or care how the rows are physically arranged, so the schema can grow without breaking the applications built on top of it.
Neither model disappeared without leaving something behind. The hierarchical model proved that a single database could enforce structure and serve many programs safely at once, and its tree shape came back decades later in XML and in document stores such as MongoDB. The network model gave the field the schema and subschema split, the separation of data definition from data manipulation, and the habit of describing a database through a formal standard, all of which carried straight into the relational systems that followed.