I wish to produce a area during my database which is simple to query.

I believe basically give a little of background this makes more sense. My table has entries proven on my small website. I operate a program which compares the entries a decides whether or not to hide them from being proven on the website. I additionally hide entries by hand for a number of reasons.

I wish to store these reasons inside a area, so several reason might be designed for hiding.

And So I need some type of logic to find out which reasons happen to be used.

Can anybody offer me any assistance with what's going to be future-proof also known as new reasons and what's going to be fast and simple to question upon ?

you stated

one listing has numerous good reasons to be hidden

you implement the "someone to many" relationship by providing the "many"-side an overseas key pointing to among the rows inside your "one" side. within this situation this could mean two tables:


listing will most likely come with an id (int), plus some text (text).

reason_to_hide_listing may have its very own id (int), an overseas key column known as listing_id (int), along with a column named reason (text).

to discover if your listing is hidden, query the table reason_to_hide_listing for any listing_id comparable to your opportunity you'd like to learn should you display or otherwise. if a number of rows return, this listing should not be shown.

SELECT COUNT(*) FROM reason_to_hide_listing WHERE listing_id = ?;

to discover all why one listing is not displayed, choose the main reason in the table reason_to_hide_listing in which the foreign secret is the id from the listing at hands.

SELECT reason FROM reason_to_hide_listing WHERE listing_id = ?;

to cover an inventory, and simultaneously give a reason to why it's hidden, just place a brand new row in reason_to_hide_listing having a listing_id pointing towards the listing you need to hide.

INSERT INTO reason_to_hide_listing(listing_id, reason) VALUES(?, ?);