mysql - When should we go for one-to-one relation model vs adding attributes to same table? -


i'm using sails framework build website , mysql database. have table called "property". , there other details "total budget", "hold period", "rentable area", "investor share", "company share", "sale price" , many more attributes related property in one-to-one fashion.

i'm unable decide whether create separate small tables these details (by grouping them under small tables "equity", "funding",...) "property id" primary key each of small tables(creating one-to-one association on sails) or make these attributes under "property" table. adding them attributes "property" table make table big 40 columns(is problem?).

note: these attributes mandatory details , not "null" anytime.

i go 1 table, specialy if fields mandatory.

you far mysql limit , not problem.

your code easier write , read.

it better mysql performances because won't need join tables when retrieving data.


edit. one-to-one relation used in other use cases. example, let's have table "animal" contains columns "varchar name", "integer age" , "decimal weight".

but stored animals have specific properties stored in table depending on family.

  • a "dog" table columns "integer owner_id", "enum breed"
  • a "bird" table columns "boolean can_fly", "integer number_of_eggs"
  • a "fish" table columns "integer number_of_gils", "boolean live_in_freshwater"

rantanplan dog, donald duck , nemo fish stored in "animal" table , have specific properties stored in table one-to-one relation.

this silly example gives idea of use case.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -