Which type of schema is the best one?
Posted: Fri Nov 05, 2010 6:07 pm
Hi people,
I have social networking site, which store friends in it. For that i have schema as shown in the image

Type 1:
This is the basic method of storing friends, it consists of userid and friendid, but let us say a user has 500 friends on average, in that case for total users of 10,000 database contains 5,000,000 which seems pretty much scary to me.
Type 2
This schema will have only 1 row per each user, and all friendids are stored seperated by comma, for quering friends of a user we just need to select that row and explode it.
Problem is...
1.Is the second schema reliable?
2.Does it break any rules of database?
3.Is querying faster than first schema?
4.Any demerits of this schema?
Please help me .
I have social networking site, which store friends in it. For that i have schema as shown in the image

Type 1:
This is the basic method of storing friends, it consists of userid and friendid, but let us say a user has 500 friends on average, in that case for total users of 10,000 database contains 5,000,000 which seems pretty much scary to me.
Type 2
This schema will have only 1 row per each user, and all friendids are stored seperated by comma, for quering friends of a user we just need to select that row and explode it.
Problem is...
1.Is the second schema reliable?
2.Does it break any rules of database?
3.Is querying faster than first schema?
4.Any demerits of this schema?
Please help me .