App Database Design
1. Users Collection
Purpose: Stores information about students, business owners, hostel admins, and their
roles.
Structure:
users/
userId/
name: string
email: string
role: string (e.g., "student", "admin", "business_owner")
phone: string
profile_picture: string (URL)
date_joined: timestamp
address: string (optional)
business_id: string (if business_owner)
2. Hostels Collection
Purpose: Stores information about the hostels and their rooms.
Structure:
hostels/
hostelId/
name: string
address: string
admin_id: string (ref to users)
total_rooms: number
available_rooms: number
facilities: array (e.g., ["Wi-Fi", "Cafeteria", "Laundry"])
rooms/
roomId/
room_number: string
room_type: string (e.g., "single", "double")
price_per_semester: number
status: string ("available", "booked")
current_occupant: string (ref to users/userId)
date_available: timestamp
3. Bookings Collection
Purpose: Stores booking details for hostel rooms.
Structure:
bookings/
bookingId/
user_id: string (ref to users/userId)
hostel_id: string (ref to hostels/hostelId)
room_id: string (ref to hostels/{hostelId}/rooms/roomId)
booking_date: timestamp
payment_status: string ("pending", "paid")
total_amount: number
payment_id: string (ref to payments/paymentId)
booking_status: string ("confirmed", "canceled", "completed")
4. Businesses Collection
Purpose: Stores details about businesses created by students.
Structure:
businesses/
businessId/
owner_id: string (ref to users/userId)
name: string
description: string
date_created: timestamp
product_count: number
products/
productId/
name: string
description: string
price: number
category: string
stock: number
images: array (URLs)
sales_count: number
date_added: timestamp
5. Orders Collection
Purpose: Stores order details when students purchase products from businesses.
Structure:
orders/
orderId/
user_id: string (ref to users/userId)
business_id: string (ref to businesses/businessId)
product_id: string (ref to businesses/{businessId}/products/productId)
quantity: number
total_price: number
order_date: timestamp
delivery_status: string ("pending", "shipped", "delivered")
6. Payments Collection
Purpose: Stores information about payments made for bookings and product purchases.
Structure:
payments/
paymentId/
user_id: string (ref to users/userId)
amount: number
payment_method: string ("card", "paypal", etc.)
payment_date: timestamp
payment_status: string ("pending", "completed", "failed")
transaction_id: string
related_booking_id: string (optional, ref to bookings/bookingId)
related_order_id: string (optional, ref to orders/orderId)
7. Reviews Collection
Purpose: Stores reviews from students about hostels or products.
Structure:
reviews/
reviewId/
user_id: string (ref to users/userId)
target_id: string (can be hostelId or productId)
target_type: string ("hostel" or "product")
rating: number (1 to 5)
review_text: string
review_date: timestamp