design - Creating a YAML based list vs. a model in Rails -


i have app consists of restaurant model instances. 1 of essential attributes these restaurants labeling cuisine falls under. i'm @ odds myself in regards designing this. on 1 hand thought of creating cuisine model , creating either hmt or habtm association between restaurants , cuisines.

more came across post shows how create pre-defined set of attributes. take answer 1 step further i'm assuming (in case) i'd add string-based cuisine column restaurant model , setup select box in restaurant form save selected value.

what wondering efficient way of doing this? goal able query restaurants based cuisine(s) fall under. wasn't sure if model best choice due serving join table in sense name attribute. wasn't sure if having table minute optimal.

on other hand didn't know if using yaml conducive since values dummy strings no tangible records on file i'd have model instance. can me sort out confusion?

there many benefits of normalizing many-to-many relationships in db. here some:

  • searching, sorting, , creating indexes faster, since tables narrower, , more rows fit on data page.
  • you can have more clustered indexes (one per table), more flexibility in tuning queries.
  • index searching faster, since indexes tend narrower , shorter.
  • more tables allow better use of segments control physical placement of data.
  • you have fewer indexes per table, data modification commands faster.
  • fewer null values , less redundant data, making database more compact.
  • triggers execute more if not maintaining redundant data.
  • data modification anomalies reduced.
  • normalization conceptually cleaner , easier maintain , change needs change.

also, normalizing cleaner syntax , other infrastructure benefits activerecord, e.g.

cuisine.restaurants.where(city: 'toledo') 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -