Note that there are some explanatory texts on larger screens.

plurals
  1. POMysql creating lot of table or less tables, which is better?
    primarykey
    data
    text
    <p>I am currently working on a webapp that is heavily depend upon lot of data from database. Consider the following case.</p> <p><strong>A) Table design with Predefined tables only</strong></p> <pre><code>1)table vehicle_type ------------------ id|name ------------------ 1 |car 2 |truck 3 |bike ------------------- 2)table users ------------------- id|name ------------------- 1 |James 2 |John 3 |Stefen ------------------- 3)table ownership -------------------------------- id|vehicle_type_id|user_id|count -------------------------------- 1 | 1 |1 |30 2 | 1 |3 |20 3 | 3 |2 |13 -------------------------------- </code></pre> <p><strong>B) Table design with dynamically creating tables using app logic, that is when a new entry comes in vehicle_type we create a new table with that name</strong></p> <pre><code>1)table vehicle_type ------------------ id|name ------------------ 1 |car 2 |truck 3 |bike ------------------- 2)table users ------------------- id|name ------------------- 1 |James 2 |John ------------------- 3)dynamic_table car ------------------- id|user_id|count ------------------- 1 |1 |20 2 |2 |10 ------------------- 3)dynamic_table truck ------------------- id|user_id|count ------------------- 1 |3 |15 2 |2 |20 3 |1 |12 ------------------- 4)dynamic_table bike ------------------- id|user_id|count ------------------- 1 |1 |4 2 |2 |12 ------------------- </code></pre> <p>In second case table vehicle_type act as key to dynamic tables. In first I used ownership the table to store the data of count of vehicle type that each owner has, in second I create dynamic tables for each vehicle type and stores each vehicle type count in seperate table.I think this approach will make the scaling of database relatively easy and querying much efficient,than using a single table ownership. </p> <p>I have never worked with large set of data but this one will have lot of data for sure. Please note above tables are used as sampels not part of real application logic. </p> <p>Please suggest the merits and demerits of each method.</p> <p>Thanks</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.
 

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