Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8233687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:12:58+00:00 2026-06-07T18:12:58+00:00

We will be creating a MySQL database to reflect the following PHP classes: Content

  • 0

We will be creating a MySQL database to reflect the following PHP classes:

  • Content
  • Article extends Content
  • Post extends Content
  • …

There will be models associated with Content, like Comment, Ignore etc..

The question here is which data model to use.

1) One table per model

2) One large content table (with all class properties as columns), plus single tables for the other models. I believe it’s called single table inheritance.

3) A large content table with the common fields, or only the fields we commonly search on (indexes), plus a large content-data table, with the rest of the properties.

4) Another way?

We want to be able to query against the Content, and get recent, location-based or somehow filtered content, regardless of which content type (subclass) it is. Therefore solution 1 is probably out of the question.

This system should be quick and scalable. What is the best way to go about this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:12:59+00:00Added an answer on June 7, 2026 at 6:12 pm

    I wrote a blog post about this topic that you may find helpful: http://jasonswett.net/blog/composition-a-better-alternative-to-orm-inheritance/

    First, I’d like to recommend that you call your table content_item or something instead of content. The reason for this is I believe the table name should match the name of the thing it represents. See this other blog post of mine for details on that.

    So you might have a table called content_item, a table called article and a table called post. content_item would have columns like title, slug, etc – everything that every content item will have, whether it be a post, article or something else. Then article would have a content_item_id and then anything else that’s specific to articles, but only what’s specific to articles. For each article, you’d have a content_item record, then an article record that’s attached to that content_item record.

    This would give you the ability to query content_item and get results that include all content types.

    I’ve implemented this kind of solution in the past with good success. (I’ve also tried different approaches and didn’t like them as much.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a PHP website connected to a MySQL database. Next I will
I am creating a mysql db with a php frontend. The data it will
The following program I'm creating will allow the user will input values to create
Im creating a Yii app where i will save images into the database. Now
I'm creating dynamic website with Php and Mysql. So i need insert bangla language
After dynamically creating a client-side table based on SELECT information retrieved from MySql database,
For a web application, when creating the user which will connect to the MySQL
I am creating an iphone app that will run an SQLite database. I want
I am creating a site in PHP while storing my date in a MySQL
I need some help creating a query for my mySQL database. I have recently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.