Search code examples
phpmysqlarrayslistblacklist

How to create a "blacklist" in MySQL?


I'm making an application in PHP in which employers can accept or reject offers from workers. If you click on the reject button, a function will be called with the id of the offer you want to reject. Now here's my problem, I don't know how to manage those decisions; I have thought maybe making a table to assign the rejecting offer id to the employer email but that would cause a big unordered and difficult to handle table.

I have also thought about making a new field in the employer row, an array, in which I'll store all rejected offers, and another field for the accepted ones of course. What do you think would be a good option? (Doesn't have to be one of this I named)


Solution

  • Think about the relationships: An Employee can receive many Offers, and an Offer can be sent to many Employees. It's a many-to-many relationship. You need a join table. It has a primary key that is the composite of the Employee and Offer primary keys. Each one is a foreign key relationship to the table it came from.

    There might be other attributes associated with each row in that join table: a creation timestamp, a flag indicated if it was accepted or rejected, and the acceptance timestamp.

    These are fundamentals of relational databases. You can't design an application well without understanding them.