Remaining Seats/Reservations

Hi, Im making an app that can reserve seats for an Event. I’ve managed to build a database that can remember a user and his family that is reserving spots.

But im stuck at showing the remaining number of seats/spots.

Also how do i lock the database in case 2 or many users are trying to reserve at the same time?

Any help would be much appreciated.