Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm current working on a SQLite-database in a android project which will store 3 types of objects; feed, users and posts.

There will be several feeds containing several varying users(a user can be part of serveral feeds) and of my understanding i should implement this by having a Many-to-Many relationship: feedTable - bridge_feeduserTable - userTable

But there will also be posts made by users and a post should be linked to a the user which created the post. How should i link this up?

Should i have a feedTable - bridge_feeduserTable - userTable - bridge_userpostTable - postTable?
or should the posts be stored in a separate database with all the posts? What is the best practice regarding this issue?

Some basic questions that will asked to the database is:
What users are part of feed x?
What posts have been made by the users in feed x?

share|improve this question
Is every post made by one user and for one feed? Or are there posts that do not belong to a feed? –  ypercube Oct 7 '12 at 9:12
add comment

migrated from stackoverflow.com Oct 7 '12 at 5:39

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 1 down vote accepted

If I get you right then one post is linked to one user but one user can have many posts. I think this is a one to many relationship. So, put a field user_id in your table post then you know which post is linked to which user.

It's a german page but the first image would help you.

share|improve this answer
Sorry, i was not clear enough. The bridge_userpostTable will have a user_id and a post_id which ofcourse will enable a query for a user_id (giving ID to all posts). Do you think the bridge_userpostTable is unnecessary and a postTable with user_id column is enough? –  Rawa Oct 5 '12 at 21:49
Do you think the bridge_userpostTable is unnecessary and a postTable with user_id column is enough? <- If one post is linked to one user then yes. If one post is linked to many users then you need three tables. I UPDATET THE ANSWER –  JackTools.Net Oct 5 '12 at 22:01
Thanks for the answer, the picture added resolved my question. (: –  Rawa Oct 5 '12 at 22:29
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.