Google Cloud Storage & Database
☁️ Google Cloud Storage & Databases — Easy Explanation
Suppose we build a food delivery application like Swiggy/Zomato.
Our application needs to store many types of data:
- User profiles
- Restaurant information
- Food images
- Orders
- Payments
- Delivery locations
- Reviews
- Notifications
- Millions of transactions
We shouldn't put all this data into one type of storage.
Why?
Because different data has different requirements.
For example:
Food image ↓ Needs to store a file Order ↓ Needs transactions User profile ↓ Needs application database Millions of sensor readings ↓ Needs huge-scale database
That's why Google Cloud provides different storage/database services.
1. First understand the 4 types of data
The video mentions:
Structured, unstructured, transactional, and relational data.
Let's understand each.
🟦 A. Structured Data
Structured data has a fixed format/schema.
For example, an employee table:
| ID | Name | Age | Department |
|---|---|---|---|
| 101 | Shivam | 25 | IT |
| 102 | Rahul | 28 | HR |
It's organized into:
Rows + Columns
This is structured data.
Examples
- Employee records
- Customer records
- Bank transactions
- Product information
- Orders
Think:
Structured = organized like an Excel/table.
2. 🟨 Unstructured Data
Unstructured data doesn't naturally fit into rows and columns.
Examples:
📷 Image 🎥 Video 🎵 Audio 📄 PDF 📦 Backup file
For example, a photo:
pizza.jpg
You don't normally store the actual image inside a table like:
| ID | Image |
|---|---|
| 1 | ???? |
Instead, you store the file somewhere designed for objects/files.
That's where Cloud Storage comes in.
3. 🟩 Transactional Data
Transactional data is data involved in an operation that must be handled correctly.
Imagine you transfer ₹1,000.
Account A ₹10,000 ↓ Transfer ₹1,000 Account B ₹5,000
After the transaction:
Account A ₹9,000 Account B ₹6,000
We don't want this to happen:
Account A ₹9,000 Account B ₹5,000
Money disappeared!
So transactions need strong consistency and reliability.
Examples:
- Bank payments
- Orders
- Account balances
- Inventory
- Ticket booking
4. 🟥 Relational Data
Relational databases organize data into tables and relationships between those tables.
For example, an online store might have:
CUSTOMER --------- customer_id name email
and:
ORDER --------- order_id customer_id amount date
The customer_id connects the two.
Customer ↓ Customer ID ↓ Orders
This is the idea behind a relational database.
Common relational databases include:
- MySQL
- PostgreSQL
- Oracle
- SQL Server
Google Cloud has Cloud SQL for this type of workload.
⭐ Now the 5 Google Cloud Products
The video introduces:
1. Cloud Storage 2. Cloud SQL 3. Spanner 4. Firestore 5. Bigtable
Don't try to memorize their definitions immediately.
Instead, think:
What problem does each one solve?
1️⃣ Cloud Storage
What is Cloud Storage?
Cloud Storage is Google's object storage service.
Think of it like a huge cloud-based hard drive/file storage system.
You can store:
📷 Images 🎥 Videos 📄 PDFs 🎵 Audio 📦 Backups 📁 Application files
Example
Suppose you create a YouTube-like application.
Users upload videos:
video1.mp4 video2.mp4 video3.mp4
You don't want to store these large files in a normal SQL database.
Instead:
Application | ↓ Cloud Storage | ├── video1.mp4 ├── video2.mp4 ├── video3.mp4 └── video4.mp4
Cloud Storage terminology
Cloud Storage stores objects inside buckets.
Think:
Bucket | ├── image1.jpg ├── image2.jpg ├── video1.mp4 └── document.pdf
Easy analogy
Your computer:
Folder ↓ Files
Google Cloud:
Bucket ↓ Objects
So:
Cloud Storage = store files/objects.
2️⃣ Cloud SQL
Now imagine we need to store:
Customer Order Product Payment
These are structured and relational.
Cloud SQL is a managed relational database service.
It supports popular relational database engines such as:
- MySQL
- PostgreSQL
- SQL Server
Example
Suppose we have:
Customer table
customer_id | name ------------|------- 1 | Shivam 2 | Rahul
Orders table
order_id | customer_id | amount ---------|-------------|------- 101 | 1 | ₹500 102 | 1 | ₹300 103 | 2 | ₹800
This is a relational database.
Cloud SQL manages much of the underlying infrastructure for you.
Why "managed"?
Without Cloud SQL, you could install PostgreSQL yourself on a VM:
VM | PostgreSQL | You manage everything
You'd have to worry about things like:
- backups
- updates
- maintenance
- availability
- database administration
With Cloud SQL:
Your Application | ↓ Cloud SQL | PostgreSQL
Google manages much of the database infrastructure.
Easy memory:
Cloud SQL = managed traditional relational database.
3️⃣ Spanner
Spanner is one of the most important products to understand.
Think:
Spanner = globally scalable relational database.
Imagine a huge company operating worldwide.
India | Europe | USA | Singapore
It needs a database that can scale massively while providing strong consistency and relational capabilities.
That's where Spanner comes in.
Example
Imagine a global banking application:
Customer in India | ↓ Spanner ↑ | Customer in USA
The database can be distributed across regions while maintaining strong consistency characteristics.
Why not just Cloud SQL?
Cloud SQL is excellent for many traditional relational applications.
But imagine your application becomes enormous.
You need:
Massive scale + Global distribution + Relational database + Strong consistency
Spanner is designed for this type of workload.
Easy memory:
Cloud SQL = traditional relational database
Spanner = globally scalable relational database
4️⃣ Firestore
Now let's talk about Firestore.
Firestore is a NoSQL document database.
This means the data isn't primarily organized like traditional SQL tables.
Instead, it uses documents organized into collections.
Example
Suppose you have a mobile application.
A user:
Shivam
might have a document:
users | └── user123 | ├── name: Shivam ├── age: 25 ├── city: Pune └── premium: true
This is a document-oriented approach.
Firestore is great for application data
Imagine you're building a chat application.
You might have:
users ↓ messages ↓ conversations
Firestore is designed for application development where you need flexible document data and easy synchronization patterns.
It's particularly popular for:
- Mobile applications
- Web applications
- Real-time application experiences
- User profiles
- Chat applications
- Application state
SQL vs Firestore
SQL
TABLE ---------------- id | name | age 1 | Shivam | 25
Firestore
DOCUMENT { name: "Shivam", age: 25, city: "Pune" }
The structure is different.
Easy memory:
Firestore = NoSQL document database for application development.
5️⃣ Bigtable
Now we come to Bigtable.
Bigtable is designed for very large-scale, low-latency workloads.
Think:
Millions ↓ Billions ↓ Trillions
of data points.
Example: IoT sensors
Imagine a company has:
1 million sensors
Each sensor sends data every second:
Sensor 1 → temperature = 30°C Sensor 2 → temperature = 28°C Sensor 3 → temperature = 31°C ...
That's an enormous amount of data.
Sensors | ↓ Bigtable | ├── Sensor 1 ├── Sensor 2 ├── Sensor 3 └── ...
Bigtable is designed for massive-scale analytical/operational workloads where very high throughput and low latency are important.
🚨 Bigtable vs Firestore
This is another common confusion.
Firestore
Think:
Mobile/Web App ↓ Firestore
Good for application-oriented document data.
Bigtable
Think:
Huge data ↓ IoT ↓ Telemetry ↓ Time-series / large-scale workloads ↓ Bigtable
🧠 Now put all 5 together
Here's the easiest picture:
Google Cloud Storage Options | ┌───────────┬───────┼────────┬──────────┐ ↓ ↓ ↓ ↓ ↓ Cloud Storage Cloud SQL Spanner Firestore Bigtable | | | | | Files SQL Global NoSQL Massive /Objects Database SQL Documents scale
🍕 One application example
Let's build a food delivery application.
We could use multiple services at the same time.
Restaurant images
restaurant.jpg food.jpg logo.png
➡️ Cloud Storage
Customer/order database
Customer Order Restaurant Payment
➡️ Cloud SQL
Global food delivery platform
If we need a globally distributed, highly scalable relational database:
➡️ Spanner
Mobile app user data
User profile Preferences Chat Application data
➡️ Firestore
Delivery vehicle/sensor data
Vehicle 1 → GPS → 10:01:01 Vehicle 1 → GPS → 10:01:02 Vehicle 1 → GPS → 10:01:03 ...
At enormous scale:
➡️ Bigtable
⭐ The most important comparison
| Product | Think about | Example |
|---|---|---|
| Cloud Storage | 📁 Files/objects | Images, videos, backups |
| Cloud SQL | 🗃️ Traditional relational DB | Orders, customers |
| Spanner | 🌎 Global relational DB | Global banking/application |
| Firestore | 📱 NoSQL document DB | Mobile/web app data |
| Bigtable | 📊 Massive-scale data | IoT, telemetry, time-series |
🔥 Easy interview/exam trick
When you see files, think:
📁 Cloud Storage
When you see MySQL/PostgreSQL/SQL Server, think:
🗃️ Cloud SQL
When you see global + relational + massive scale, think:
🌎 Spanner
When you see NoSQL + documents + mobile/web app, think:
📱 Firestore
When you see huge-scale + low latency + IoT/telemetry, think:
📊 Bigtable
One final picture to memorize
WHAT DO I NEED TO STORE? | ┌──────────────────┼───────────────────┐ | | | FILES DATABASE HUGE DATA | | | ↓ ↓ ↓ Cloud Storage Which type? Bigtable | ┌────────┼─────────┐ ↓ ↓ ↓ SQL Global NoSQL | SQL | ↓ ↓ ↓ Cloud SQL Spanner Firestore
🎯 In one sentence:
Cloud Storage stores files, Cloud SQL stores traditional relational data, Spanner provides globally scalable relational storage, Firestore stores NoSQL documents for applications, and Bigtable handles massive-scale, low-latency data workloads.
Comments
Post a Comment