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.