Reputation: 12684
I'm creating a database for booking apartments app.
I have a question - it is allowable to keep user's passwords
in DB (for example using BCrytp)?
Another question - where is the best way to keep price
if it may vary during several months?
Upvotes: 0
Views: 2919
Reputation: 502
Yes you can use Bcyrpt(specifically py-bcrypt) to encrypt the password and stored into the database. The Bcrypt hash is safe and it is used in many applications.
Also if your price of the apartment changes for several month or after several months then you can add one more colmun (eg Last_updated) to your apartment table. This will append the current date when you enter the price for the first time to your table. Now create a trigger that will change the Last_Updated date when the price of the apartment changes. This will let you know the last time (date) you updated price of your apartment.
Also you can create one more table that keeps track of your change in price. The table will have the (apartment_id, old_price, new_price, last_updated). Using this you can keep track of both the last updated date and the old price.
Upvotes: 1
Reputation: 3301
typically, you would store the password as some sort of encrypted hash. It is best if this is one-way, so it cannot be decrypted. When authenticating, you check that you can generate the same hash from the provided password; not decypt what is stored. Your hash should also be "salted" with some other data so two users with the same password don't have the same hash (so, using the username itself is popular).
If your prices vary, you'll want a separate table for prices that have date from and date to fields so you know the period of time the price is valid. Unless, you are saying that each "booking" can have a price - then you could just put the price in the booking table.
Upvotes: 1