Say we were modeling Users and Friends, and Friends have a type.
We could model it in Oracle like:
User: id, name, sex, age
Friendship: user_id, friend_id, type
So in HBase, we could do:
(this first model is from here, which is recommended by the HBase FAQ)
Table: Users
RowKey = <user_id>
Column Family = Info; Columns = "Name", "Sex", "Age"
Column Family = Friend; Columns = "Friend:<user_id>"=type
(where "Friend:"=type could be one more more user_ids)
or
Table: Users
RowKey = <user_id>
Column Family = Info; Columns = "Name", "Sex", "Age", "Friends"
(where "Friends" is a JSON string in the form [{user_id:, type:}, ...]
However, if a friend did not have a type, the second model could simply be [user_id:<user_id>, ...]
. What would the first model do if friends didn't have a type?
What are the pros and benefits of either approach?