I am working on a social networking site and it has a wall like facebook where user can post status, pics and stuff. Building a wall just for a user is not hard thing. I have structure like this.
Wall
{
Id,
ToUserId (BigInt) (Owner of wall)
ByUserId (The person who is posting)
Content (message, pic or something else)
more fields....
}
This wall is just for a user, I cant reuse it, For example, I am thinking site will have
other objects too like Pages, Groups etc. so all the objects will have Wall for them. I dont want to create separate table for each wall.
Then I thought, I can have ObjectId instead of ToUserId and my structure will be like this.
Wall
{
Id,
ObjectId (BigInt)(PageId/UserId/GroupId (one of them))
ByUserId (The person who is posting)
Content (message, pic or something else)
more fields....
}
As I am using Increment field in my tables, A page can have same Id which a user has. so that is again a problem.
Next, I thought, my object should be string type
Wall
{
Id,
ObjectId (string(10))(PageId/UserId/GroupId (one of them))
ByUserId (The person who is posting)
Content (message, pic or something else)
more fields....
}
Now for a User, I will append “U” to the number so Object Id’s will be “1U”,”2U” and for pages they will be “1P”,”2P” and for a group “1G”, “2G”.
But I am still not convince, Would like to hear to expert advice on this.
Update
Thanks guys, The problem, I am having is, how can I keep one table for all types of walls.
A wall for a User
A Wall for a Page
A Wall for a Group
If you look at facebook, its one wall or atleast, I want to build it, so it should be attached to any object (to a user, to a page or to a group or to anything).
I hope this makes more sense now.
I don’t understand why you’re trying to create some kind of “string” reference structure. That doesn’t seem “relational”.
How about this.
POCO’s (because i can’t be bothered writing SQL)
Assumptions: