Welcome Guest, Not a member yet? Register   Sign In
Mapping URL hierarchy to relational database


if I type some URL (with several fragments), how to find out which rows corresponds to it?

Say, if I type "/animals" I would like to retrieve "lion" and "elephant". If I type "/animals/small" I would like to get "bee" and "mouse".

In other words, I would like to simulate an ordinary file system with folders and files in SQL.

I can enumerate recursively from the first segment to the last one, but that calls DB many times. Is it possible to with fixed amount of SELECTs? I also read about "materialized path", where I would simply store the URL and the data into the same row. But if I then rename a segment (or a folder, in file system terms), I would need to correct all the affected rows.

I also saw:
which, if I understood correctly, says that the "node enumeration" (i.e. "materialized path") should be the best fit. But is it?

To summarize: For a given URL, how to find which DB rows do fit under it?

Theme © iAndrew 2016 - Forum software by © MyBB