E
E
E6APB2017-08-19 12:07:21
MySQL
E6APB, 2017-08-19 12:07:21

What is the best way to store this in a database?

Taxi service. Order table. The order has its own executor - the carrier. The driver has a car. What is better to store in orders? Create a driver_id and car_id columns or create a car_id column and use it to search for a carrier using join?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
i_visseri, 2017-08-19
@E6APB

I thought about your task and concluded that it is probably better to store both car_id and driver_id in orders. I'll try to explain my vision - even if we remove car_id and it will be in the driver's plate, then all the same, to report the description of the car to the user, we will have to do a JOIN. From JOIN'ov we will not leave anywhere. But such a case is possible: the user can select a car on the go by class (econom, business) and then it is logical to update the order line in accordance with the selected car. That is, from the point of view of your subject area, an order is a driver + a car (of a different class). But this is just my opinion, it would be interesting to hear others.

E
entermix, 2017-08-19
@entermix

cars
id, numberplate, ...

drivers
id, car_id, first_name, last_name, ...

clients
id, phone_number, ...

orders
id, driver_id, client_id, sum, ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question