0

I'm currently working on making a Reddit clone and I'm in the design process at the moment. I'm trying to wrap my head around OOD, UML, and the relational schema.

So, a user can make two types of posts: link post and text post. Both types of posts have similar attributes like title, which subreddit to post to, and date created. So, for my OOD, I want to have a Post parent class that has these attributes, but also can't be instantiated, so I decided to make it an abstract class and create the two sub classes, TextPost and LinkPost, extend from the parent.

So when it comes to the database tables, how do I model this correctly? Do I have a post table that has these attributes then just join the subclasses when I need them?

For instance, if I wanted to get all text posts, I'd have something like:

"select * from posts inner join text posts on post.id = textpost.id"

which means I'd have all posts stored in a post table along with the different types of posts in their respective tables?

Should I not have a post table since it's an abstract class in my OOD?

So I'm really hung up on how to design my DB when I have an abstract class in my OOD. I'd really appreciate it if someone could clear my confusion.

Thank you for your time.

DJG
  • 65
  • 8
  • I do have sort of an unusual story about this very topic. On another site I had a post with a recurring update about building a Forum system like Reddit and the owner of the site deleted a whole bunch of the code and my explanation of things. The butchered thread is still there and it describes a system like what you're interested in seemingly. In my opinion OOD is useless to solve the issue of persisting threaded conversations – SteveC Jul 17 '21 at 22:53
  • [This is what's left](https://www.sqlservercentral.com/forums/topic/forum-api-project/page/2) of the content. When asked about missing posts: "I'll try to search those out, but not sure." – SteveC Jul 17 '21 at 22:56

0 Answers0