educative.io

UserPhoto and UserFollower inefficient to store using column family DB like Cassandra

Its mentioned UserPhoto and UserFollower can be stored using column family DB like Cassandra.

In column DB, we mention column name while creating table, each row can have its own set of columns.

Say for example “UserPhoto” table, user can have multiple photos association. While creating UserPhoto column DB table, we will not be able to specify how many columns as each “PhotoID” value should be one column. User photo association will be keep growing, how can we create dynamic columns in table to hold “PhotoID” information.

Here, key-value store fits good for UserPhoto. As we can just store “,” separated Photo IDs with UserID as key.

Kindly, help me to clear my doubt, how UserPhoto relation can be stored in Cassandra.

1 Like

NoSQL allows you to add columns on the fly.

UserPhoto Table

userID            photo123      photo345      photo567       photo789
---------------------------------------------------------------------
user123             Y               null            Y            null
user345             null             Y              null         null

NoSQL does not need to store null value. No wasted space.