Skip to main content
Tweeted twitter.com/StackDBAs/status/658514715950358528
edited title
Link
oucil
  • 516
  • 2
  • 7
  • 19

Performance impact of NOT using a foreign key (...OR... is EAV justifedmany dedicated 1:many key-key tables vs non-fk generic key-key table)

updated title
Link
oucil
  • 516
  • 2
  • 7
  • 19

Performance impact of NOT using a foreign key (...OR... is EAV justifed)

deleted 27 characters in body
Source Link
oucil
  • 516
  • 2
  • 7
  • 19
  1. I use polymorphic object structures, but every object is stored in it's own table, i.e. user, product, category, event, etc.

  2. As far as the proposed ass table, it will only have 4 functional fields, with very straightforward datatypes (plus one ai_col as primary). The datatypes would be varchar(10) for the type cols and CHAR(32) / BINARY(16) for the id's. SELECT's will only ever have one join, to the ass table, i.e.

    SELECT event.* FROM event INNER JOIN ass ON ass.obj_1_type = 'event' AND ass.Object_ID_1 = event.Event_ID AND ass.obj_2_type='location'SELECT event.* FROM event INNER JOIN ass ON ass.obj_1_type = 'event' AND ass.Object_ID_1 = event.Event_ID AND ass.obj_2_type='location'

  1. I use polymorphic object structures, but every object is stored in it's own table, i.e. user, product, category, event, etc.

  2. As far as the proposed ass table, it will only have 4 functional fields, with very straightforward datatypes (plus one ai_col as primary). The datatypes would be varchar(10) for the type cols and CHAR(32) / BINARY(16) for the id's. SELECT's will only ever have one join, to the ass table, i.e.

    SELECT event.* FROM event INNER JOIN ass ON ass.obj_1_type = 'event' AND ass.Object_ID_1 = event.Event_ID AND ass.obj_2_type='location'

  1. I use polymorphic object structures, but every object is stored in it's own table, i.e. user, product, category, event, etc.

  2. As far as the proposed ass table, it will only have 4 functional fields, with very straightforward datatypes (plus one ai_col as primary). The datatypes would be varchar(10) for the type cols and CHAR(32) / BINARY(16) for the id's. SELECT's will only ever have one join, to the ass table, i.e.

    SELECT event.* FROM event INNER JOIN ass ON ass.obj_1_type = 'event' AND ass.Object_ID_1 = event.Event_ID AND ass.obj_2_type='location'

simplified
Source Link
oucil
  • 516
  • 2
  • 7
  • 19
Loading
deleted 91 characters in body
Source Link
oucil
  • 516
  • 2
  • 7
  • 19
Loading
added 30 characters in body
Source Link
oucil
  • 516
  • 2
  • 7
  • 19
Loading
added clarifications
Source Link
oucil
  • 516
  • 2
  • 7
  • 19
Loading
Source Link
oucil
  • 516
  • 2
  • 7
  • 19
Loading