Note that there are some explanatory texts on larger screens.

plurals
  1. POObject and Object meta schema design
    primarykey
    data
    text
    <p>Am working on a project that will save many types of objects into the database. These include: articles, polls, writers .. etc. Some of those are unknown to me at design time so what i am trying to do is build a generic table schema that will enable me to save any type of item into this database.</p> <p>My design</p> <p><strong>Table Object</strong></p> <pre><code>objectID int title varchar body text type int #will represent the ID of the type of object am inserting </code></pre> <p>Having that circumstances or requirements might need additional data, i decided that this will go to what i call "object metadata" as follows:</p> <p><strong>Table Object_MetaData</strong></p> <pre><code>metaID int metaKey varchar metaIntKey int #representing an integer value of metaKey which is calculated using some algorithm to speed up queries metaValue varchar(1000) </code></pre> <p>I am doing all the work in PHP and MySQL btw.</p> <p>A couple of things came up to my mind when doing this design regarding the performance of the database on the long run:</p> <p>1) Is saving int, boolean, small text, big text into the metaValue effecient?</p> <p>2) on the long run the metadata table is going to grow quite quickly. Is this a maintainance nightmare? how is MySQL going to to handle this?</p> <p>3) IN php when fetching objects, i will have to loop each object to fetch its metadata, or load all metadata once using lazy loading or load any single metakey once its requested via __get magic method. So when fetching a list of say 50 objects, at least 50 select statements will be executed when using any of the methods i suggested. Is there a better more efficient way of doing this?</p> <p>Any thoughts or comments on this design are welcome.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload