Storage
Storage holds large files like images, videos, and PDFs, working alongside the database.
In one sentence
Storage is the warehouse for 'big files' (images, videos, PDFs), dividing labor with the database.
In Plain Language
Large files like images, videos, and PDFs don't belong in the database — they make it bloated and slow. They should go into dedicated object storage, such as Cloudflare R2 or AWS S3.
The common approach: the file itself lives in storage, and the database only records "the file's URL or ID". When it needs to be shown, the frontend fetches it straight from storage by URL — fast and cheap. Watch permissions carefully: private files must not be downloadable by anyone who guesses the URL.
Architecture
How It Flows
Database or File Storage?
When you're not sure where something belongs, sort it by shape:
- Structured records — users, orders, posts, comments — go in the database, where they can be queried, sorted, and related.
- Large files — images, video, PDFs, attachments — go in file/object storage, which is built for big binary blobs.
The two work together: the database stores a link to the file (its URL or ID), not the file itself.
Key Takeaways
- Big files go to storage; the database only stores the URL or ID.
- The split keeps the database fast and lets storage handle capacity.
- Always set access permissions on private files — don't let people download by guessing URLs.
An everyday analogy
The database is the front-desk logbook; storage is the large warehouse out back. The logbook only notes 'which shelf the item is on'.
Pros
- Great for large files — low cost, big capacity
- Files can be served directly via URL, which is fast
- Divides labor with the database, each doing its job
Cons
- If permissions aren't set, private files may be publicly accessible
- You need to manage file naming and lifecycle
Good for
- Apps that upload avatars, photos, videos, attachments
- Hosting images and assets for static sites
Not for
- Structured data needing complex queries and relations (that's the database's job)
Beginner scorecard
- Beginner-friendly
- 4/5
- Learning cost(higher = more cost)
- 3/5
- Market demand
- 4/5
- AI-generation friendly
- 4/5
Frequently asked questions
Do I store files like images and videos in the database?
No. Databases store text and numbers; large files like images and videos go in object storage (like Cloudflare R2 or S3), and the database just keeps their URL.
How is object storage different from a regular disk?
Object storage is accessed over the network by URL, scales almost infinitely, and is billed by usage — ideal for user uploads. A local disk vanishes the moment a serverless environment restarts.
How do I make images load faster?
Put files in object storage and pair it with a CDN that caches them at the node nearest the user; also compress images and use modern formats (WebP/AVIF).
Next in SaaS Path: PostgreSQL →