Assume we have a parking lot with 500 parking spots. Each spot has 12 cars parked on average everyday. Then we'll have 500 * 12 * 365 = 219000
For each parking, we should have info like car plate number, parking id, start time, end time, etc. Assume each parking info is 1KB, then the total storage is 219000 * 1KB * 5yrs = 11GB
Reserve a slot
check-in
check-out
If the system is reserved but the user does not show, the system will still start charging based on the start time and rating. If the user still does not checkin with 24 hours, then this reservation will be cancelled, and the user will be charged for 24 hours parking fee.
Consistency vs availability
When user is booking a parking lot, we should ensure the consistency of the data to avoid double booking on the same lot.
To avoid single point of failure, we should replicate the database. The master node is used to handle all the write queries, and slave nodes are used to handle all the read requries.
If there are more and more parking buildings, then we need to consider a distributed system which may require database partitioning.