Peter Hickman wrote:
> To be honest I would go with
>
> user_id :integer
> title :string
> forename :string
> midname :string
> surname :string
> suffixes :string
> gender :string
>
> and 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.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.