educative.io

UserFollow table confusion

“For the ‘UserPhoto’ table, the ‘key’ would be ‘UserID’ and the ‘value’ would be the list of ‘PhotoIDs’ the user owns, stored in different columns. We will have a similar scheme for the ‘UserFollow’ table.”

Does that mean pk is userID and value is a list of userID the user follows?

And in the pic, UserID1 and UserID2 are both primary keys. I think we there is only one primary key allowed in db.

2 Likes

I would also like to know the answer to this

Cassandra for relation storage confuses me as well. If I understand it right, in one row we store users that are related to some exact user id (for example, followers that follow some user). In this case, to get a list of followers we need to retrieve the whole row and this doesn’t look like a correct usage of columnar DB since operation on the whole row is relatively slow for columnar DB. Am I missing anything?

UPD. Nevermind, I misunderstood an idea. Each column is a set of followers that are related to some user.

I guess the schema is for SQL database, and they choose NoSQL later instead. I am still so confused about which 1 is better over the other. Without using joins in SQL db, we still can use it. SQL & NoSQL both can be horizontally scaled nowadays. I just don’t know how to respond to interviewer when asked the pros and cons.