3

I am Adding User's Posts and Comments Capability to my Android Application, I thought A lot about it, in My Sight, There Are 2 Ways To Acheive That :

  1. Create a Table For Each New Post and Let it Hold Comments, Likes,Dislikes
  2. Create 2 Databases , 1 For Keeping Postsid and Comments ID , and Second for Keeping Original Comments With Given ID.

First is A lot Easier and More Comfortable but Would MYSQL Database be Able to Deal Well With too many Tables in That , or Is There a Better Way For That?

Also I Need to Give Posts Life Time of about 24h, Is There Any Way to Do so too?

halfer
  • 19,824
  • 17
  • 99
  • 186
reza
  • 197
  • 2
  • 14

1 Answers1

4

I think better solution is to have 3 tables:

  • for posts (fields: id, long varchar)
  • for likes/dislikes (fields: id, postID, int representing likes/dislikes or 2 fields for that)
  • for comments (fields: id, postID, long varchar)

All that is so easy to manage (you can retrieve all post, likes/dislikes and comments with 1 single query). Maybe its easy to develop but not in performance in terms of database usage. Doing this you can implement likes dislikes in comments.

if you use innoDB as engine you can delete/update on cascade if relations are well defined

You can define scheduled jobs with mySQL in order to delete all info every day: How to schedule a stored procedure in MySQL

another good ideas about your problem: MySQL give rows a lifetime

Salut!

Community
  • 1
  • 1
gienini
  • 88
  • 1
  • 7
  • I Accept Answer for the Deleting Schedule Way, The DataBase Is Actually Not Possible to Perfom, Thanks Alot – reza Aug 28 '14 at 10:40