Note that there are some explanatory texts on larger screens.

plurals
  1. PODatabase design rules to follow for a programmer
    primarykey
    data
    text
    <p>We are working on a mapping application that uses Google Maps API to display points on a map. All points are currently fetched from a MySQL database (holding some 5M + records). Currently all entities are stored in separate tables with attributes representing individual properties. </p> <p>This presents following problems:</p> <ol> <li><p>Every time there's a new property we have to make changes in the database, application code and the front-end. This is all fine but some properties have to be added for all entities so that's when it becomes a nightmare to go through 50+ different tables and add new properties.</p></li> <li><p>There's no way to find all entities which share any given property e.g. no way to find all schools/colleges or universities that have a geography dept (without querying schools,uni's and colleges separately).</p></li> <li><p>Removing a property is equally painful.</p></li> <li><p>No standards for defining properties in individual tables. Same property can exist with different name or data type in another table.</p></li> <li><p>No way to link or group points based on their properties (somehow related to point 2).</p></li> </ol> <p>We are thinking to redesign the whole database but without DBA's help and lack of professional DB design experience we are really struggling. </p> <p>Another problem we're facing with the new design is that there are lot of shared attributes/properties between entities.</p> <p>For example:</p> <p>An entity called "<strong>university</strong>" has 100+ attributes. Other entities (e.g. hospitals,banks,etc) share quite a few attributes with universities for example atm machines, parking, cafeteria etc etc.</p> <p>We dont really want to have properties in separate table [and then linking them back to entities w/ foreign keys] as it will require us adding/removing manually. Also generalizing properties will results in groups containing 50+ attributes. Not all records (i.e. entities) require those properties. </p> <p><em>So with keeping that in mind here's what we are thinking about the new design</em>:</p> <ul> <li><p>Have separate tables for each entity containing some basic info e.g. id,name,etc etc.</p></li> <li><p>Have 2 tables <strong>attribute type</strong> and <strong>attribute</strong> to store properties information.</p></li> <li><p>Link each <strong>entity</strong> (or a table if you like) to <strong>attribute</strong> using a many-to-many relation.</p></li> <li><p>Store addresses in different table called <strong>addresses</strong> link entities via foreign keys.</p></li> </ul> <p>We think this will allow us to be more flexible when adding, removing or querying on attributes.</p> <p>This design, however, will result in increased number of joins when fetching data e.g.to display all "<strong>attributes</strong>" for a given university we might have a query with 20+ joins to fetch all related attributes in a single row.</p> <p>We desperately need to know some opinions or possible flaws in this design approach.</p> <p>Thanks for your time.</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