0

I'm designing a database for a platform where users can post different types of content.

Database Engine: SQL Server

The system includes:

  • Proposals

  • Experiences

  • Events

##Current Schema Design##

Proposals

  • id (primary key)
  • user_id (references Users)
  • title
  • description
  • location
  • date
  • max_participants
  • confirmed_participants
  • created_at

Experiences

  • id (primary key)
  • user_id (references Users)
  • title
  • description
  • location
  • happened_at
  • created_at

Events

  • id (primary key)
  • user_id (references Users)
  • title
  • description
  • location
  • event_date
  • ticket_price
  • ticket_url
  • created_at

Data Volume & Query Patterns

Frequent queries:

  • Retrieve all posts of a specific type (e.g., all events).
  • Retrieve all posts across all types (for a global feed).
  • Fetch a single post by ID, regardless of type.
  • Filter by date, location, category, and user engagement (likes, comments).

Since all post types share common fields (id, user_id, title, description, location, created_at), I considered a Table Per Type (TPT) approach to avoid duplication.

Publication (Base Table)

  • id (primary key)
  • user_id (references Users)
  • title
  • description
  • location
  • created_at

And then, the other tables would inherit from Publication, having the publication_id as PK,FK.

I leave here a diagram that shows how would it finally be if this approach is taken (I cannot embeded it but it but you can check it in the following link).

Database modelling

This way, I could retrieve all posts using a query on the Publication table. However, I have concerns about:

  1. Query Performance: Would querying across multiple inherited tables be efficient in SQL Server?

  2. Joins & Indexing: Since I'll frequently need to filter by type, will inheritance make indexing and joins more complex?

  3. Alternative Approaches: Would it be better to store all post types in a single table with nullable columns, or should I just keep separate tables with no inheritance?

esta bien formulado?

1
  • "Since all post types share common fields [...], I considered a Table Per Type (TPT) approach to avoid duplication." What do you mean by duplication? Commented Feb 27 at 23:48

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.