4 ms·
Yes, the first way, the adjacency list, has the simplest table layout and still lets you set foreign keys. I strongly recommend PostgreSQL's WITH RECURSIVE quer
by combatentropy 10y ago
Yes, the first way, the adjacency list, has the simplest table layout and still lets you set foreign keys. I strongly recommend PostgreSQL's WITH RECURSIVE queries to go along with it (https://www.postgresql.org/docs/current/static/queries-with.html https://www.postgresql.org/docs/current/static/queries-with....). Or now that I know SQLite has it, I recommend either one over MySQL. Writing such queries is mindbending for a while. But it's worth it to be able to take care of it all in the database. Before, I would write a function in PHP that did a database query, then called itself to do another database query, and so on until it was done.