Say I have a table of users with an id column and a ranking column. Each user can rank the other users in some order. Let's say this list can be very long (max of some constant, say 10,000), but will often be much shorter. It will only be necessary to store and retrieve a user's whole list, that is, each list will not need to be e.g. searched in a query.
An idea is to store this as a list of ids in the form of a comma-separated string. The only downside to this is that a foreign key cannot connect each id in a list to its id column in the respective user, meaning if the id of a user changes, it will not automatically change in the lists. However, a user's id will never change, so this is a matter of principle (not breaking 1NF?).
Another idea is to create a table where each entry has a from and to user id column as well as a ranking column. The downside of this is that the table can potentially contain a very large number of records (e.g. billions) compared to the number of users. Also, when retrieving the list of a user, it needs to search through the many records. There is repetition of data, e.g. the ranking is now stored explicitly, rather than implicitly, this means making one change in the list can mean all records belonging to that list have to have their ranking column updated.
What is the better solution? Is there a different solution entirely?
Edit: I think most will say the second is best because it is a relational database, however, can you say the negative aspects could be mitigated or why they don't matter? What if the ordered lists could be even longer, e.g. millions of elements each, so the lists would be more like a blob of data and an equivalent table could contain trillions of entries?
When using a table the user will probably need to have the ranking copied over to an array in a front-end language to edit it and so either each change will have to be made both on front-end and back-end, or the old records must be deleted and a new record for each element of the new list inserted.