Spaces:
Sleeping
Sleeping
Database Schema
This document reflects the active SQLAlchemy models in data/models.py.
Engine and Initialization
- ORM: SQLAlchemy 2.x
- Base class:
data.db.Base - Default DB:
sqlite:///./notebooklm.db - Initialization:
data.db.init_db()
Relationship Overview
users1:Nnotebooksnotebooks1:Nsourcesnotebooks1:Nchat_threadschat_threads1:Nmessagesmessages1:Nmessage_citationssources1:Nmessage_citationsnotebooks1:Nartifacts
Tables
users
Columns:
idINTEGER PKemailVARCHAR(255) NOT NULL UNIQUE INDEXdisplay_nameVARCHAR(255) NULLavatar_urlVARCHAR(1024) NULLcreated_atDATETIME(timezone=True) NOT NULL
notebooks
Columns:
idINTEGER PKowner_user_idINTEGER NOT NULL FK ->users.idON DELETE CASCADE INDEXtitleVARCHAR(255) NOT NULLcreated_atDATETIME(timezone=True) NOT NULLupdated_atDATETIME(timezone=True) NOT NULL
sources
Columns:
idINTEGER PKnotebook_idINTEGER NOT NULL FK ->notebooks.idON DELETE CASCADE INDEXtypeVARCHAR(50) NOT NULLtitleVARCHAR(255) NULLoriginal_nameVARCHAR(1024) NULLurlVARCHAR(2048) NULLstorage_pathVARCHAR(1024) NULLstatusVARCHAR(50) NOT NULLingested_atDATETIME(timezone=True) NULL
chat_threads
Columns:
idINTEGER PKnotebook_idINTEGER NOT NULL FK ->notebooks.idON DELETE CASCADE INDEXtitleVARCHAR(255) NULLcreated_atDATETIME(timezone=True) NOT NULL
messages
Columns:
idINTEGER PKthread_idINTEGER NOT NULL FK ->chat_threads.idON DELETE CASCADE INDEXroleVARCHAR(20) NOT NULLcontentTEXT NOT NULLcreated_atDATETIME(timezone=True) NOT NULL
message_citations
Columns:
idINTEGER PKmessage_idINTEGER NOT NULL FK ->messages.idON DELETE CASCADE INDEXsource_idINTEGER NOT NULL FK ->sources.idON DELETE CASCADE INDEXchunk_refVARCHAR(255) NULLquoteTEXT NULLscoreFLOAT NULL
artifacts
Columns:
idINTEGER PKnotebook_idINTEGER NOT NULL FK ->notebooks.idON DELETE CASCADE INDEXtypeVARCHAR(50) NOT NULLtitleVARCHAR(255) NULLstatusVARCHAR(50) NOT NULLfile_pathVARCHAR(1024) NULLmetadataJSON NULL (mapped asartifact_metadata)contentTEXT NULLerror_messageTEXT NULLcreated_atDATETIME(timezone=True) NOT NULLgenerated_atDATETIME(timezone=True) NULL
Notes
- Ownership and isolation are anchored by
notebooks.owner_user_id. - Child records are deleted via
ON DELETE CASCADE. - Schema creation is currently handled with
Base.metadata.create_all(...)(no Alembic yet).