July 2010
Intermediate to advanced
840 pages
16h 33m
English
Most SQL databases use the adjacency list model for two reasons. The first reason is that Dr. Codd came up with it in the early days of the relational model, and nobody thought about it after that. The second reason is that the adjacency list is a way of “faking” pointer chains, the traditional programming method in procedural languages for handling trees. It is a recording of the edges in a “boxes and arrows” diagram, something like this simple table:
CREATE TABLE AdjTree (child CHAR(2) NOT NULL, parent CHAR(2), -- null is root PRIMARY KEY (child, parent)); AdjTree child parent ============= 'A' NULL 'B' 'A' 'C' 'A' 'D' 'C' 'E' 'C' 'F' 'C'
The queries for the leaf nodes and root are obvious. The root has a NULL parent, ...
Read now
Unlock full access