How to create a database collection that is formula-based

Hello, I am creating a cost per wear app. I have 5 database collections so far (user, closet item, logged item, item color, item category). I want users to be able to 1) add an item to their closet 2) log that item each time they wear it and 3) calculate cost per wear of that item (item original price/# of times item is logged). I don’t know how to make cost per wear a collection in my database bc it is formula-based. Can someone please provide some advice with this?