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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:41:24+00:00 2026-06-09T00:41:24+00:00

My question relates to a php website with a mysql database. Currently in the

  • 0

My question relates to a php website with a mysql database.

Currently in the database we have a ‘token’ entity

a token can hold 0 or more ‘object’ entities and each of these objects can be of type x, y, z

so

----------
| Token  |
|--------|

--------------
|token_object|
|            |
|tokenID     |
|objectID    |
--------------

------------
| object   |
|          |
|objectType|
------------

------------  --------- ---------
| objectX  |  |objectY| |objectZ|
|          |  |       | |       |
------------  --------- ---------

Now this works okish, because when I want the data from an object which, due to the nature of our caching system, is almost always one object at the time I can just make two queries to get the data from object and objectX/Y/Z

(SELECT * FROM object WHERE id = $id) 

and

switch($objectType)
case 'objectX':
    SELECT * from ObjectX WHERE id = $id
case 'objectY':
etc etc..

But now I’ve been asked to allow users of the website to create new object types, ie objectA/B etc.

I could just create a new objectXn table for each new object type, and by choosing a good value for objectType that would work

(SELECT * FROM $objectType WHERE blabla)

but that doesn’t seem to be a very clean solution, especially the creation of new tables

Are there any better solutions?

Worth noting is that I expect that there are a lot of objects relative to tokens and that the creation of extra object types won’t happen a lot/almost never

  • 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-09T00:41:25+00:00Added an answer on June 9, 2026 at 12:41 am

    What exactly are you storing? Does it need complex queries against it or do you need a simple object-storage by id? In the latter case, you can create a table that has an ID, Type and Data, where data is the serialized object that you can restore in your code (for example, storing your object as JSON, and de-serializing it with the stored Type and the Data). A little more context in your question is appreciated if this doesn’t satisfy your needs.

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

Sidebar

Related Questions

I am using PHP to query the MySQL database on my website. Please answer
I'm designing a website using PHP and MySQL currently and as the site proceeds
I have a question relates to PHP and Java programming. I am going to
i have a PHP/mySQL question related to virtuemart ecommerce - I've asked on the
This question specifically relates to my experience with PHP, but there's no reason why
I am using git to manage a dynamic website (PHP + MySQL) and I
My question relates to identifying which table and schema a mysql command is executed
I currently have the following code for EVERY page on my website. Please could
This relates to my previous question (which can be viewed here ). I'd like
This question relates to: PHP Version 5.3.6 Microsoft Drivers for PHP for SQL Server

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.