Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nildunhill's avatar

📣 NEED SUGESTIONS 📣

Hey guys!! disclaimer first. This is not a coding related questions. Well, because i thought this is a forum then i guess we can share some knowledge.

So i'm creating a contest registration web application using Laravel + ReactJs. The CRUD for managing the contest is already done. But there is a question come up into my mind. Here are the questions (p.s. I need advice since I'm lack of experience 😊) :

Questions

  1. How do i implement realtime database?
  2. How to prevent DB racing?

Context for each questions

  1. this question come up into my mind because when one of the admin is updating the status of a contest (from active to inactive) how to let the other admin know that one of the contest data is updated already? So it don't updated twice. Or maybe it's not a big thing that i should worry about? need sugestions...
  2. Now because this web will be accessed by public. I'm afraid there will be a DB racing case when it comes to attaching the users to the contests (Yes it's a Many-to-Many relationship. So User can participate in 1 or more contest and vice versa). Well in my intermediate table, i don't have id. But, i have created_at and updated_at. Or maybe once again this question only came into my mind because i overthink to much?? hahahahah

Please let me know if u guys have any suggestions and Thank you so much for your attention. May u guys have a good day 😉

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

1.very unlikely

If this is a serious concern, one safeguard is to add the updated_at field to the form data when it is sent to the client. Put this in a hidden field. When the form is submitted, if the database updated_at is newer than the one in the form data then throw a validation error and tell the user that the record was updated since they loaded it.

2.very unlikely.

I imagine adding a user to a competition will involve writing a record to the pivot table containing the user_id and the competition_id. Writing a single row to a table is unlikely to have race condition issues since you don't need to query the data before inserting this record.

1 like

Please or to participate in this conversation.