Metadata Database Design
What You'll Learn
You'll learn how to design a dedicated database for tracking file metadata in an image/video hosting system, keeping structured properties separate from the actual binary content stored in object storage.
Why Separate Metadata from Blobs?
When storing images and videos, you have two distinct types of data:
- The actual file (blob) – potentially gigabytes per video, best stored in object storage
- Information about the file (metadata) – owner, size, upload date, permissions – structured data perfect for relational databases
Think of it like a library: the books (blobs) sit on shelves (object storage), while the library catalog (metadata database) tells you what books exist, who checked them out, and where to find them.
Core Metadata Schema
Your metadata database should track:
file_id– unique identifier (primary key), often a UUIDowner_id– which user uploaded itfile_size– bytes stored, for quota enforcementfile_type/mime_type– image/jpeg, video/mp4, etc.created_at/updated_at** – timestamps for lifecycle trackingstorage_location– S3 bucket path or CDN URL pointing to the blobstatus– processing, available, deleted
This separation lets you:
- Query efficiently: "Show all videos uploaded by user X" without scanning massive files
- Scale independently: relational metadata database can be optimized differently than object storage
- Maintain consistency: one source of truth for ownership and permissions, even if storage tiers change
Storage Location Pointers
The storage_location field is critical—it maps the metadata record to the actual blob. For example:
s3://my-bucket/images/abc123.jpg or https://cdn.example.com/videos/xyz789.mp4
This indirection lets you migrate storage backends without changing file identities.
Key Takeaway:
Store file metadata (ID, owner, size, type, timestamps, location) in a relational database separate from blob storage to enable fast queries, independent scaling, and clear separation of structured properties from binary content.