Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design Interview - Car Reservation System [closed]

Tags:

oop

A Car Reservation System is a very popular question in Software Development Interviews. I designed the following ER structure/OOP structure when I was asked this:

Car class/table has Car Id#, Type (Compact, Standard, etc), Make, Model Customer has Customer Id#, etc Reservation is an associative table storing Car Id#, Customer Id# and Date for which the car is reserved. For the sake of simplicity we can assume that car can be reserved only in chunks of days.

Here's the tricky part where I floundered - What happens when a customer 1 reserves a compact car having Id Car 3 on July 27. What happens if Car 3 is totaled on July 24. Other compact cars are available, however between July 24 and 27 they all get taken. So when Customer 1 arrives on July 27, he ultimately has no car.

The flaw I think is in the way Car and Customer are coupled in the Reservations table. Is there any better way to model this relationship and also the regular use cases such find an available car for a particular date, reserve it for that date etc.

like image 597
Tilottama Gaat Avatar asked Aug 01 '12 12:08

Tilottama Gaat


People also ask

What happens in system design interview?

In a System Design Interview, interviewers ask the candidate to design a web-scale application. For example, they might ask you to design Instagram, design YouTube, or design Uber backend. Unlike a coding interview question, System Design Interviews are free-form discussions, and there's no right or wrong answer.

Is system design interview hard?

System design interview questions separate junior and senior engineering roles. They're difficult to prepare for because, unlike algorithm questions, they don't boil down to a handful of prescribed patterns. Instead, they draw upon a vast ocean of technical knowledge and experience.


1 Answers

You can add another boolean field to Car called Working. If Car 3 is totaled then

  • set Working to false.
  • search for it in Reservation.
  • if it's there, then search for another car of that type in Car.
  • if found then replace this car with the other car in Reservation.
  • else call the customer.
like image 72
Avi Cohen Avatar answered Nov 30 '22 11:11

Avi Cohen