I’m creating a tree view for a website using databases. I will create 2 tables, let’s call them “Folder” and “File”. A folder can contain multiple folders and files, and files will act as leaf nodes – which means they’re a “dead end” in the tree if you’re unfamiliar with the term.
The folder table will contain columns:
Folder_id, Folder_name, Folder_parent
File will contain:
File_id, File_name, File_parent
Obviously File_parent will reference a folder_id, thus creating a foreign key, but how do I make the Folder_parent reference the Folder_id?
Example:
FOLDER_NAME | FOLDER_ID | FOLDER_PARENT
root 1 null
Cars 2 1
Planes 3 1
BMW 4 2
1 Answer