Peter H. wrote:
To be honest I would go with
user_id :integer
title :string
forename :string
midname :string
surname :string
suffixes :string
gender :stringand treat midname as a space separated list of names (although this
wont handle names like ‘st clair’ correctly).
Storing multiple values in a single column break First Normal Form (1NF)
and is always a bad idea IMHO. If fact having multiple fields for the
parts of names also technically breaks 1NF because it is a repeating
group. name1, name2, name3, etc. Naming them as above actually obscures
this fact.
For a fully robust solution we need to eliminate the repeating group:
Baby
id :integer
gender :string
Methods:
def full_name
@components = NameComponent.order(:position)
@components.join(’ ')
end
def name_component_at_index(index)
NameComponent.where(:position => index)
end
def append_name_component
…
…
end
def insert_name_component_at_index(index)
…
…
end
NameComponent
id :integer
baby_id :integer
position :integer
name :string
Although I showed some example convenience methods above, one could use
something like acts_as_list (or of the derivatives of that) for managing
the list of name components.