Note that there are some explanatory texts on larger screens.

plurals
  1. POis EAV - Hybrid a bad database design choice
    primarykey
    data
    text
    <p>We have to redesign a legacy POI database from MySQL to PostgreSQL. Currently all entities have 80-120+ attributes that represent individual properties.</p> <p>We have been asked to consider flexibility as well as good design approach for the new database. However new design should allow:</p> <ul> <li><p><strong><em>n</em></strong> no. of attributes/properties for any entity i.e. no of attributes for any entity are not fixed and may change on regular basis.</p></li> <li><p>allow content admins to add new properties to existing entities <strong>on the fly</strong> using through admin interfaces rather than making changes in db schema all the time.</p></li> </ul> <p>There are quite a few discussions about performance issues of EAV but if we don't go with a hybrid-EAV we end up:</p> <ul> <li>having lot of empty columns (we still go and add new columns even if 99% of the data does not have those properties)</li> <li>spend more time maintaining database esp. when attributes keep changing.</li> <li>no way of allowing content admins to add new properties to existing entities</li> </ul> <p>Anyway here's what we are thinking about the new design (basic ERD included):</p> <ul> <li><p>Have separate tables for each entity containing some basic info that is exclusive e.g. id,name,address,contact,created,etc etc.</p></li> <li><p>Have 2 tables attribute type and attribute to store properties information.</p></li> <li><p>Link each entity to an attribute using a many-to-many relation.</p></li> <li><p>Store addresses in different table and link to entities using foreign key.</p></li> </ul> <p><img src="https://i.stack.imgur.com/VIBk0.png" alt="alt text"></p> <p>We think this will allow us to be more flexible when adding,removing or updating on properties.</p> <p>This design, however, will result in increased number of joins when fetching data e.g.to display all "attributes" for a given stadium we might have a query with 20+ joins to fetch all related attributes in a single row.</p> <p>What are your thoughts on this design, and what would be your advice to improve it.</p> <p>Thank you for reading.</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.
 

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