Skip to content

Instantly share code, notes, and snippets.

View maxcelos's full-sized avatar
💭
Looking for awesomeness

Marcelo Silva maxcelos

💭
Looking for awesomeness
View GitHub Profile
@maxcelos
maxcelos / sql-folders-tree.md
Created October 19, 2024 23:47
An example of database table and use case with entity recursive relationship.
drop table if exists folder;

create table folder (
	id INTEGER primary key AUTOINCREMENT, -- Primary key for the folder, automatically incremented
	name TEXT not null, -- Name of the folder
	parent_id INTEGER, -- Foreign key referencing the parent folder
	foreign key (parent_id) references folder (id) -- Self-referencing foreign key
);