Forum Discussion

feralvarez994's avatar
feralvarez994
Helper II
4 years ago

Model relationship

Hi everyone! I have an issue here

 

I have 3 tables (Autos, Reserva, and LOG_RESER).

- In TABLE RESERVA i have every car booking/reservation (every booking has 1 key) with each Code of the car booked

- In TABLE AUTOS i have every car (booked, not booked, used as part of payment, not used as part of payment, etc) with the cost and everything else

- In LOG_RESER i have only the cars that were used as part of payment and the booking asociated

 

RESERVA (RE) & AUTOS (AT) are linked by the car code, each booking has one car linked (1 to * relationship in both direction, columns AT_COAUTO to RE_COAUTO)

Autos & LOG_RESER are linked also by the car code from AT_COAUTO to COD_AUTO (1 to 1 both directions)

 

The thing is that i have to bring the Cost of the COAUTO (find it in table AUTOS with AT_COSTO) that has been used as part of payment, so i can identify it in LOG_RESER table (RESERVA table only has the car code associated to the book, not to the part of payment), and that cost I have to subtract it from the total debt that the reservation has (it is in another column of the reservation table called DEUDA_TOTAL or TOTALDEBT)

 

Hope to be clear!

 

1 Reply

  • v-luwang-msft's avatar
    v-luwang-msft
    Community Support

    Hi feralvarez994 ,

    Is it possible to show some template data, and the expected output? Remember to remove confidential data.

     

     

    Best Regards

    Lucien