Reducing app logic to database layer (any guides centered around that)

So I’m creating a recrusive database schema/controller which basically just fills it up with reservations for hotel rooms. The way that I intend to do that is to derive actual reservations by finding non-reservations that match a query and letting user update it as their own and their date ranges. The way that I’d populate the database after each reservation is run, is a function really dependent on arrays, are there any extensive guides on that or prefferably example apps? The insert isn’t defined, but the function should run on startup and update.