home
diamond Go Premium
Data Engineering Path  ·  Data Modelling
PARKING SYSTEM CASE STUDY

Step 3: Relationships Explained (Parking Lot)

Banner

1. Multi-Level Physical Hierarchy

To represent the physical parking architecture, we enforce cascading one-to-many relationships:

  • A parking_lot hosts multiple parking_floors (one-to-many: lots.lot_id ➡️ floors.lot_id).
  • Each parking_floor contains many individual parking_spots (one-to-many: floors.floor_id ➡️ spots.floor_id).

This structure guarantees that we can aggregate active occupancy statistics at the specific floor level as well as across the entire garage structure instantly.


2. Spot Allocation & Session Lifecycles

When a driver pulls up to an entry terminal and triggers ticket generation:

  1. The system queries available spaces matching their vehicle size class.
  2. A single parking_spots record status is flagged as 'OCCUPIED'.
  3. A new tickets record is initialized, storing the assigned spot_id and the entry_time timestamp.
-- Atomic spot state transition upon entry
UPDATE parking_spots
SET status = 'OCCUPIED'
WHERE spot_id = ? AND status = 'AVAILABLE';

3. Dynamic Billing Invoicing

Upon vehicle exit, the database calculates total elapsed minutes:

  • elapsed_hours = CEIL(EXTRACT(EPOCH FROM (exit_time - entry_time)) / 3600)
  • The calculated value is matched against the specific parking_rates slab configured for the target lot_id and matching spot_type.
  • The final sum is stored in tickets.amount_charged and must be matched by a corresponding entry in payments with a unique transaction reference before the exit boom-gate is commanded to open.
lock

This content is reserved for Premium Members.

Upgrade to Premium

Entity Details

Create New Item

help

Submit Technical Query

Have a question or run into an issue? Describe it below, upload an optional screenshot, and our engineering team will answer it!

image Attach image (optional)

Submit Feedback

build Free Developer Utility Free Tool
gavel

Privacy & Legal Disclaimer

1. Client-Side Browser Processing

All utility tools on DeepEngineerHub (including Image to PDF, Text Formatters, JSON Converters, and Encryptors) execute 100% locally within your client browser using WebAssembly and JavaScript. No uploaded images, text, or documents are transmitted, collected, or stored on remote servers.

2. Limitation of Liability ("As-Is" Provision)

Tools and services are provided free of charge for convenience and educational purposes "as-is" without warranties of any kind. DeepEngineerHub shall not be held liable for any data loss, formatting inconsistencies, or indirect damages resulting from tool usage.

3. Open Source & Third-Party Software

Certain utilities utilize open-source client libraries (such as jsPDF, Mermaid.js, Pyodide) licensed under MIT, Apache, or BSD open licenses. All intellectual property remains with their respective copyright holders.