Can a binary tree or tree be always represented in a Database table as 1 table and self-referencing?

Posted by Jian Lin on Stack Overflow See other posts from Stack Overflow or by Jian Lin
Published on 2010-06-06T06:46:36Z Indexed on 2010/06/06 6:52 UTC
Read the original article Hit count: 225

I didn't feel this rule before, but it seems that a binary tree or any tree (each node can have many children but children cannot point back to any parent), then this data structure can be represented as 1 table in a database, with each row having an ID for itself and a parentID that points back to the parent node.

That is in fact the classical Employee - Manager diagram: one boss can have many people under him... and each person under him can have n people under him, etc. This is a tree structure and is represented in database books as a common example as a single table Employee.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about database-design