2

I'm working on an application which would mimic the Twitter Lists functionality in which someone can follow someone else. Each user can also create objects which can be followed by users. The Twitter Lists functionality is the best example of the functionality I am wanting to create.

What would this database model look like? I was planning to use Parse.com, but would be open to any representation of the domain model.

Edit: I'll try to add to why I'm asking. Right now I have this structure (only showing the relevant relationship fields):

User
- username
- activities : Relation<Activity>
Activity
- name
- owner : Pointer<User>
- followers : Relation<User>
Follow
- from : Pointer<User>
- to : Pointer<User>
Subscription
- from : Pointer<User>
- to : Pointer<Activity>
ActivityPost
- activity : Pointer<Activity>
- from : Pointer<User>
- to : Relation<User>

I read through the Parse Anypic tutorial found here: Anypic tutorial. They did something strange to me by combining three relationships into a single table. This makes me think I've perhaps gone overboard with my join tables.

0

1 Answer 1

1

I'll try to explain why they merge all relationships into one table.

Whether a users follows, likes or comments a photo all these activities are somewhat similar they involve a user and photo. Note that the comment also requires some text.

So instead of having 3 tables like your data model they went with one.

I don't like that approach though because it merges data that may is similar in its appearance but differs in meaning. Also the comments require extra data (content) that is empty for likes and follows. Having the type described as a string as in their example is also bad (better make an extra table).

A database model would like this for your problem

User(**UserID**, Name, ....)
Post(**PostID**, UserID[FK]Data, Timestamp, ...)
Follow_Users(**UserID[FK]**, **FollowingUserID[FK]**)
Follow_Posts(**UserID[FK]**, **PostID[FK]**)

However this is a database model and not a Data model. A Data model that is kept in memory within some application will be different because it features pointers to other objects and arrays...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.