Hacker News new | past | comments | ask | show | jobs | submit login

just for your sanity in a relational database alway put a root id for hierarchies. Also, you might want to skip the null and use a self reference depending on how you need to build the hierarchy. Root only matters if you have multiple hierarchies in a table.



+1 for root-id, this is a huge failing in a lot of threaded discussion table designs.


Yeah, it really helps if you have to do some processing in the stored procedures and it helps with the query speed if properly indexed. I have seen folks put a level number in the table also, but that really depends on what the hierarchy represents.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: