0

I have query regarding allocation in MySQL

I have a table which have lists of Resources (Let's assume a URL which can be allocated to only 1 user unless task is complete)

Here's the schema-

RESOURCE TABLE-

+=======================+
| ID | Resource | InUse |
|-----------------------|
| 1  | URL_1    | 0     |
| 2  | URL_2    | 0     |
| 3  | URL_3    | 0     |
| 4  | URL_4    | 0     |
+=======================+

User Table-

    +============================+
    | ID | UserName | ResourceID |
    |----------------------------|
    | 1  | User1    | 0          |
    | 2  | User2    | 0          |
    | 3  | User3    | 0          |
    | 4  | User4    | 0          |
    | 5  | User5    | 0          |
    | 6  | User6    | 0          |
    | 7  | User7    | 0          |
    +============================+

So based on above structure, let's assume I have 4 Resource, which I have to allocate to users when they request. Let's assume 3 User click button(which allocates resource) concurrently, how can I allocate without overlapping requests ?

I can use both PHP, NodeJS Apologies if it's duplicate. So Far I haven't found solution

Divyam Solanki
  • 451
  • 2
  • 5
  • 24

0 Answers0