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 7550027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:06:32+00:00 2026-05-30T10:06:32+00:00

Is it bad to implement supertype and subtype to the entire data in a

  • 0

Is it bad to implement supertype and subtype to the entire data in a database? I need some advice on this before moving to this direction…

For instance,

I have these tables as objects and they are related,

users
pages
images

entities table as the supertype

entity_id     entity_type
1             page
2             page
3             user
4             user
5             image
6             image

users table

user_id     entity_id
1           3
2           4

pages table

page_id     entity_id
1           1
2           2

images table

image_id     entity_id
1            5
2            6

here is the table to map images table with entities table because some images belong to certain page (maybe to blog posts, etc in the future),

map_entity_image table

entity_id    image_id
1            1
1            2

so, I will insert a row into the entities table when I have a page, an image, an user, etc to be created.

in the end of the day the rows in this tables will increase in a great numbers. so my worry is that can it cop with large numbers of rows? will this database gets slow and slower in time?

after all, are these a bad structure?

or maybe I am doing supertype/ subtype incorrectly?

edit:

I think the entity should have these data only,

entity_id     entity_type
1             page
2             page

unless I want to attach images to users, etc. then it should be like this,

entity_id     entity_type
1             page
2             page
3             user
4             user

maybe I am wrong…

EDIT:

so this is the query how I find out how many images attached to the page id 1,

SELECT E.*, P.*, X.*,C.*
FROM entities E

LEFT JOIN pages P ON (P.entity_id = E.entity_id)

LEFT JOIN map_entities_images X ON (X.entity_id = E.entity_id)

LEFT JOIN images C ON (C.image_id = X.image_id)
WHERE P.page_id = 1

returns 2 images.

  • 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-05-30T10:06:33+00:00Added an answer on May 30, 2026 at 10:06 am

    If all you need is to attach images to users and pages, I’m not sure a full-blown category (aka. “subclass”, “subtype”, “inheritance”) hierarchy would be optimal.

    Assuming pages/users can have multiple images, and any given image can be attached to multiple pages/users, and assuming you don’t want to attach images to images, your model should probably look like this:

    enter image description here


    You could use category hierarchy to achieve similar result…

    enter image description here

    …but with so few subclasses I’d recommend against it (due potential maintainability and performance issues). On the other hand, if there is a potential for adding new subclasses in the future, this might actually be the right solution (ENTITY_IMAGE will automatically “cover” all these new subclasses, so you don’t need to introduce a new “link” table for each and every one of them).

    BTW, there are 3 major ways to implement the category hierarchy, each with its own set of tradeoffs.

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

Sidebar

Related Questions

This is probably v.easy but my php is very rusty. I need to implement
My so far not-so-bad version to implement this is: function bashFileConvert($file) { return preg_replace('/([^\/\s]+\s+[^\/]+)(\/|$)/','${1}${2}',$file);
I want to implement some various algorithms for practice, just to see how bad
Quick question: Would it be a good or a bad idea to implement my
Not very technical, but... I have to implement a bad words filter in a
I want to apologize for my bad english first. I am trying to implement
Is this a bad idea? Private Class GH_DataStructureEnumerator(Of Q As Types.IGH_Goo) Implements IEnumerable(Of Q)
I'm trying to implement some sort of 'just-for-me' game engine and the problem's plot
Is it a bad idea to ensure that a log directory exists before every
How would I implement a enumeration field in a database that doesn't support enumerations?

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.