What is better to use, user meta, custom taxonomies or new database structure? [closed]

In the case where you want to store each piece of data as a unique entry (row) in the database, then a custom table, as you’ve already done, is a perfectly fine solution.

On the other hand…

You could use the usermeta table to do the exact same thing, storing multiple meta keys with the same name as unique entries,

Entries in the usermeta table would look like the following:

umeta_id   user_id  meta_key   meta_value
    1         1     follower     user_1
    2         1     follower     user_2
    3         1     follower     user_3
    4         1     randomkey    abcdef
    5         1     follower     user_4

As you can see in the example above, the fourth entry in the usermeta table is for a piece of completely unrelated metadata, so that is what you will contend with, all kinds of data mixed into the one table. Overtime, if this table contains a lot of extra meta information in addition to your follow-data then it can possibly effect the performance of your queries.

Personally I would create a custom table and only store user_id and follower_id (possibly the follower_username too).

primary_id  user_id  follower_id follower_username
    1          1         2            name2
    2          1         2            name2 
    3          2         5            name5  
    4          1         8            name8 
    5          1         3            name3 

Storing the username along with the ID is optional but useful.

Then I’d also store a serialized value of all people following a user against the individual user within usermeta table which you can do periodically via wp_cron. If you need to show a given user who is following them, you can retrieve an individual usermeta meta_key, unserialize the data and present it accordingly.

If you happen to also store the username of the follower, the serialized data for a user will also contain the username which will avoid you needing to run a lookup on the returned ID if all you need to show is a username and possibly a link to the user.

The ID is returned if you need to perform any additional data retrieval and manipulation which you can do from the username alone but, an ID is always handy and for me, it’s preferred.

Of course all of this is highly generalized because it really depends on your extended use case as to what you may do.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)