+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 23

Thread: Database design advice needed

  1. #1
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,758
    Blog Entries
    2
    Rep Power
    8

    Database design advice needed

    Hello people
    Sorry for the non-descriptive title

    I need to make something like Facebook's Wall.
    So there can be 2 kind of posts - normal text post and image post.

    So should i keep all info in 1 table like

    -WallPosts
    PostId
    UserId
    PostType (1 for Text post, 2 for Image post - for easy sorting)
    DateTime
    Comment/Text
    ImageURL
    Or try having them in 2 tables
    -WallPosts
    PostId
    UserId
    DateTime
    PostType

    -WallPostDetails
    Id
    PostId
    Text/Comment
    ImageURL
    What will be more efficient if say large number of records are there?
    Also not to mention my query writing capabilities

    Or any other approach?

    .NET 2.0
    SQL Server 2000


    Thanx
    Micky

  2. #2
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    I'd say store them in one table. I can't see much advantage in storing them in seperate tables.

    I presume you could have a post with image and text? How would this be handled with 2 tables?

    Probably best to get the opinion of one of our database experts though...

  3. #3
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,758
    Blog Entries
    2
    Rep Power
    8

    Thanx RR, I am also thinking of 1 table only......... cant really see or foresee any benefit of 2 tables!

  4. #4
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by micky View Post
    Thanx RR, I am also thinking of 1 table only......... cant really see or foresee any benefit of 2 tables!
    I guess the only advantage would be if you'd want to run queries seperately on the posts and posts data. You'd probably see a small performance advantage. Can't really see any circumstance where you'd query one table without the other though. In which case you may as well store all the info in one table. I would also assume the relationship between the tables would be 1 to 1. Ie each record in one table would have a corresponding entry in the other table. As I understand it, this sort of design should be avoided in most circumstances.

  5. #5
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,758
    Blog Entries
    2
    Rep Power
    8

    Well said RR

    Cant see where just any one table might be called.......... so more reasons to have 1 table.

    I see this as table structure
    -WallPosts
    PostId
    UserId
    FriendId (If any friend posts on my wall)
    PostType (1 for Text post, 2 for Image post, may be more)
    DateTime
    Comment/Text
    Details (Image URL, etc)
    Also, i think i should save entries like - "Micky is friends with RR"........... also in this table only.
    RR's id will saved in field "Details"

  6. #6
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    I think you're maybe referring to the Facebook "News Feed" rather than the wall. I think they are 2 different things. I don't know how Facebook store the xxx is friends with yyy, as the yyy is a link to their profile. If they store the whole feed in one table then I presume they store the link as facebook markup.

    So, any action that posts to the feed; Making friends, Someone posting on your wall etc. would make an entry in the "news feed" table as it will appear and also as the item in the specific table. ie a wall post in the "wall" table, a friends link in the "friends" table.

    Don't know if the "news feed" can go right back to day 1, ie when you joined. That would be a massive table.

  7. #7
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,758
    Blog Entries
    2
    Rep Power
    8

    "News Feed" shows all your entries and also friends entries.

    But this "xxx is friends with yyy" is also shown Wall....... and to link back to friend's profile, i said of storing the id of friend in field "Details"

    I am not even close to thinking about how i will be able to implement "News Feed"

  8. #8
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by micky View Post
    "News Feed" shows all your entries and also friends entries.

    But this "xxx is friends with yyy" is also shown Wall....... and to link back to friend's profile, i said of storing the id of friend in field "Details"
    Oh, is it...Not a huge facebook user... I guess store a similar entry in the "wall" table then. Like I said above, I'd guess FB store the user link as markup. They have there own markup language. So, say they had something like <fb:user id="12" /> (Don't know is this a real FB markup!) the markup engine would rewrite this to <a href="http://www.facebook.com/user.php?id=12">this user</a>. Also prevents any potential injection attacks as you can't use HTML in any posts, only FBML.

    Quote Originally Posted by micky View Post
    I am not even close to thinking about how i will be able to implement "News Feed"
    Don't know if what I suggested would work. The only other thing I can think of is you'd have to have some sort of mirrored table design with the same fields in each and then use a union to join them all together. Probably get pretty messy.

    Hope that helps..

  9. #9
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,758
    Blog Entries
    2
    Rep Power
    8

    ha...... never knew abt FB markup language

    and yes.... "messy" is the word here

    Thanx for inputs RR......... would be nice if some more people pitch in

  10. #10
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by micky View Post
    ha...... never knew abt FB markup language
    Here you go....Facebook Markup Language (FBML) - Facebook Developers
    Quote Originally Posted by micky View Post
    Thanx for inputs RR......... would be nice if some more people pitch in
    Think you'll have to wait a little longer for the US to come fully onboard...

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. Database Design Thoughts?
    By BLaaaaaaaaaarche in forum Database Design Help
    Replies: 6
    Last Post: June 28th, 2010, 09:21 AM
  2. advice / opinions on displaying 4 database values
    By Centurion in forum HTML & CSS Help
    Replies: 11
    Last Post: April 21st, 2010, 10:56 AM
  3. Replies: 2
    Last Post: March 18th, 2009, 01:18 PM
  4. Database Design
    By dtz in forum Database Design Help
    Replies: 15
    Last Post: March 13th, 2009, 08:55 AM
  5. Database table design
    By Ziggy in forum Database Design Help
    Replies: 17
    Last Post: February 16th, 2009, 01:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO