title: Reverse generic relations and Generic Relations - Database design improvement
body: <p>In a simple scenario, where I have many <code>measurements</code> table that describe the measurements that comes from a specific protocol and every measurement is linked to the respective parent device, I was looking for an optimization of my database, putting all the measurements into a table and reference from this table the respective device.</p>
  
  <p>Now, keeping in mind that this table is heavily used in read/write and especially in filtering operations, I was looking for a smarter solution...I've found the Django Generic Relations and Reverse Relations, but this approach it doesn't convince me at all because, as now, with a simple select with a where the problem is solved, but using a generic relation, the ORM will generate a lot of inner joins (if I'm not wrong) and this is an aspect that I would want to avoid. </p>
  
  <p>So, anyone with smarter idea?</p>
  
  <p>My goal is to remove tons of <code>if</code> in my code that at this time are used to decide what table it will be queried based on the protocol type, as shown below:</p>
  
  <pre><code>#MODBUS
  if smartdevice_device_parent == 'smart_device_modbus':
      ...Select from the right table and serialize the data...
  
  #RS485
  elif smartdevice_device_parent == 'smart_device_rs485':
      ...Select from the right table and serialize the data...
  
  #OPC
  elif smartdevice_device_parent == 'smart_device_opc':
      ...Select from the right table and serialize the data...
  
  #MQTT
  elif smartdevice_device_parent == 'smart_device_mqtt':
      ...Select from the right table and serialize the data...
  else:
      return JsonResponse({'success': True, 'message': (_(ERROR)),
                           'data': ''})
  </code></pre>