Car Rental Inventory
1. Introduction to Car Rental Inventory Systems:
-Purpose: track cars, availability, pricing, and rentals/returns.
-Core entities: Car, Model, Branch, Customer, Reservation, Rental, Payment.
-Why inventory matters: minimizes idle time, prevents double-booking, ensures compliance.
-Stakeholders: managers (fleet planning), desk agents (fast checkout), customepricing).
-Scope of this project: single-city rental with multiple branches and a fixedextensible later.
2. Requirements & Features:
Functional:
-Add/update/remove cars and models.
-Search available cars by date range, class, and branch.
-Book, rent-out, return, and compute bill with taxes/fees.
-Record fuel, odometer, and damages.
Non-functional:
-Data consistency via constraints and transactions.
-Simple CLI for demo; modular code for reuse.
-SQL-first design for reliable persistence.
3. Data Model Overview:
Tables:
-model(model_id, make, model_name, seats, fuel_type, daily_rate)
-branch(branch_id, name, city)
-car(car_id, vin, model_id, branch_id, status, odo_km, last_service_on)
-customer(cust_id, name, phone, email, licence_no)
-reservation(res_id, cust_id, car_id, start_date, end_date, status)
-rental(rental_id, res_id, out_time, out_fuel, out_odo, in_time, in_fuel)
-payment(pay_id, rental_id, method, amount, paid_on)
Keys & constraints:
-PKs, FKs, unique(vin), check(status in ['available','reserved','rented','service']).
4. Inventory Logic:
Car lifecycle:
- Available reserved rented available/service.
Availability check:
-A car is available for a date range if it has no overlapping reservation
Maintenance:
-Status 'service' blocks allocation; trigger can enforce min gap after service
Fleet metrics:
-Utilization = rented_days / total_days. - Idle ratio per branch, top models by revenue.
5. Pricing & Billing:
Inputs: daily_rate from model, rental days (ceil), taxes(%), optional fees
Example formula:
gross = daily_rate × days
net = gross + taxes + fees – discounts
Edge cases: partial-days rounding, grace period, max cap per rental, promo code
6. Transactions & Concurrency:
Use transactions to keep data consistent across: reserve rent-out return payment.
Isolation idea: SELECT ... FOR UPDATE (DB dependent) to prevent double-booking.
In SQLite (demo), we serialize within a transaction and rely on unique constant
7. SQL Techniques Used:
-DDL with CHECK/UNIQUE/FOREIGN KEY.
-DML with INSERT/UPDATE/DELETE and parameterized queries.
-Derived data via JOINs, GROUP BY, HAVING.
-Advanced flavor: views, common table expressions, window functions (if support)
-Sample reports: utilization by branch, revenue by model, upcoming returns.
8. Python Application Structure:
Layers:
-db.py: connection + schema bootstrap + helpers.
-models.py: dataclasses and CRUD wrappers.
-services.py: availability search, booking, rent, return, billing.
-cli.py: menu-based demo.
Error handling:
-custom exceptions; validation; safe commits/rollbacks.
9. Testing & Sample Data:
Seed data for 3 branches, 6 models, 12 cars, and a few customers.
Test scenarios:
-Overlapping reservations blocked.
-Service cars not bookable.
-Billing includes taxes and late fee.
Outputs are shown in SQL pages for transparency.
10. Future Enhancements:
-Real-time holds, multi-city pricing, seasonal rates.
-Damage imaging, GPS integration, and telemetry-based maintenance.
-Web UI + REST API; role-based access; audit logs.
-Shift from SQLite to PostgreSQL/MySQL with row-level locks.
-Analytics dashboards and ML-driven dynamic pricing.
Car Rental Inventory Python code
Car Rental Inventory SQL Commands & Outputs