<p>If two users are accessing same database table, how do we prevent users from overwriting each other’s data?</p>

There is no straightforward way to do that. You could use transactions to make sure that updates are resolved correctly (i.e. that you do not get partial updates) but you would probably lose the first set of changes as it will be overwritten by the second.
Two options you probably have are:
implement some locking mechanism on the application level (i.e. when someone start editing a record put some flag somewhere which would prevent another user from doing the same)
implement version control so each time someone writes to the database a
new
record is created. This way both sets of data will be in the database and you could have a logic in your application to merge them or select the one you like