Course contentsShow
← System Design
Lesson 1590 of 1,91939. Real-World System: Image and Video HostingFree lesson

Metadata Database Design

Store file metadata separately from blobs: file ID, owner, size, type, timestamps, and storage locations.

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:

  1. The actual file (blob) – potentially gigabytes per video, best stored in object storage
  2. 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 UUID
  • owner_id – which user uploaded it
  • file_size – bytes stored, for quota enforcement
  • file_type / mime_type – image/jpeg, video/mp4, etc.
  • created_at / updated_at** – timestamps for lifecycle tracking
  • storage_location – S3 bucket path or CDN URL pointing to the blob
  • status – 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.