I want to create a table called user_ports which will contain all the ports the user has opened in the database.
Instead of calling each colum as “port_80”, “port_100”
I was wondering if its possible to enter it to a colum which will be called opened_ports as an array.
But if I would like to get all the users with port 80 opened, how can I do that?
As far as I can understand, you just need to have 2 columns in the user_ports table: user_id which will reference the appropriate user, and opened_port, which will describe the specific opened port. Then you should probably declare the (user_id, opened_port) pair as a primary key. With such table structure, you could select the ids of users that opened 80 port by the following query:
You COULD store all of the ports opened by user as CSV in a single record, but this will: