What is business_uuid, and why we should use this in DB tables
business_uuid is a universally unique identifier for a business, used in addition to the normal numeric id.
I’ll explain clearly, practically, and with examples.
🔑 What is business_uuid?
business_uuid = a globally unique, non-guessable ID for a business
Example:
9f3a7c2e-4b41-4f9d-9c2e-8e4c6f1a21b7
It is usually a UUID v4 (random).
❓ Why not just use id?
id (INT) | business_uuid (UUID) |
|---|---|
| 1, 2, 3… | Random & unique |
| Guessable | Not guessable |
| Internal use | Safe for public use |
| DB-focused | API / URL / SaaS focused |
🎯 Why you SHOULD have business_uuid
1️⃣ Security (Very Important)
If you expose this in URLs or APIs:
❌ Bad (unsafe):
/api/business/12
✅ Good (safe):
/api/business/9f3a7c2e-4b41-4f9d-9c2e-8e4c6f1a21b7
No one can guess another business.
2️⃣ Perfect for Multi-Tenant SaaS
When you later:
- Add subdomains
abc.yourapp.com - Share public links
- Integrate with partners
UUID works across systems without collision.
3️⃣ Future Proof (Migrations, Sharding)
If you:
- Move data to another DB
- Merge systems
- Use microservices
IDs can clash. UUIDs never do.
4️⃣ API & Integration Friendly
External systems should never rely on internal DB IDs.
UUID = clean contract.
🧱 Recommended Table Design
business
--------
id BIGINT PK AUTO_INCREMENT
business_uuid CHAR(36) UNIQUE
business_name
business_type
industry_code
status
created_at
updated_at
🛠 How is business_uuid Generated?
Backend (examples)
Node.js
uuidv4()
PHP
Ramsey\Uuid\Uuid::uuid4()->toString();
MySQL (optional)
UUID()
🚫 When NOT to use UUID?
❌ For internal joins & performance-critical queries
✔ Use numeric id there
👉 Best practice:
- Use
idinternally - Expose
business_uuidexternally
🧠 Simple Rule to Remember
ID = database brain
UUID = public identity
✅ Final Recommendation (For Your Project)
✔ Keep both
id→ internalbusiness_uuid→ external, APIs, URLs
This is industry-standard SaaS architecture.