Appreciate this is a path well travelled probably. What''s the best way of to deal with gender. i.e. a Person is either Male or Female (generally and fot my purposes I''ll stick with that rule). So is it best to go Person with an attribute gender, or, I guess it''s best to do something like this - the rails way? Person belongs_to: gender Gender has_many: people Sorry if this is such an obvious question just want to do it right. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Might just be me, but I''ve always thought of gender as an attribute of a person in your context. I''m not sure where a gender model comes into all of this, but you may be thinking of something I''m not. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
To populate from a static array or from AR.... I had the same quandry and ended up doing it the ''rails'' way as you describe below. Although as you said, it is such a static thing that might as well use a constant array. The other question is to store M/F in Person.gender or store an integer. Since rails should be caching the model, I dont think it is a real big difference performance-wise either way. I think it probably comes down to your aesthetics, what feels right and what looks best to you. On Thu, Jul 29, 2010 at 12:25 PM, bingo bob <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Appreciate this is a path well travelled probably. > > What''s the best way of to deal with gender. > > i.e. a Person is either Male or Female (generally and fot my purposes > I''ll stick with that rule). > > So is it best to go Person with an attribute gender, or, I guess it''s > best to do something like this - the rails way? > > Person > belongs_to: gender > > Gender > has_many: people > > > Sorry if this is such an obvious question just want to do it right. > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I would use the gender attribute instead of creating a new entity in my model... But it depends on your model design -original message- Subject: [Rails] how to deal with gender From: bingo bob <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> Date: 07/29/2010 10:25 Appreciate this is a path well travelled probably. What''s the best way of to deal with gender. i.e. a Person is either Male or Female (generally and fot my purposes I''ll stick with that rule). So is it best to go Person with an attribute gender, or, I guess it''s best to do something like this - the rails way? Person belongs_to: gender Gender has_many: people Sorry if this is such an obvious question just want to do it right. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks chaps. It''s now got me thinking. This stuff is not as easy as it looks. Ive given up on gender when I realised that a name can belong to both genders! In English my app is a baby name chooser A baby can have many proposed names but only one surname. A name can be of many types, forename / middlename etc Any tips how to model this! -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
David Kahn wrote:> To populate from a static array or from AR.... I had the same quandryAccording to the way I think, a model object is something you CURD (create, update, read, or delete). Unless you''re God you''re not going to be creating or deleting genders. I''d go with a static enumeration (Male, Female or M, F or 0, 1). For the sake of the "simplest solution that could possibly work," I''d go with Male/Female. No added complexity in having to format the data for the view. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, 2010-07-29 at 19:01 +0200, Ar Chron wrote:> Might just be me, but I''ve always thought of gender as an attribute of a > person in your context.It''s not just you. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
bingo bob wrote:> Thanks chaps. > > It''s now got me thinking. This stuff is not as easy as it looks. Ive > given up on gender when I realised that a name can belong to both > genders! > > In English my app is a baby name chooser > > A baby can have many proposed names but only one surname. > > A name can be of many types, forename / middlename etc > > Any tips how to model this!The name itself should have "name", "boys", and "girls" where boys and girls are booleans. How many types? I only see two types, "forname", "middlename". Are you trying to build a baby name to put into a "shopping cart" of some sort? -- Alan Gutierrez - alan-LPwGgQyxhUi+XT7JhA+gdA@public.gmane.org - http://twitter.com/bigeasy -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> How many types? I only see two types, "forname", "middlename". Are you > trying to build a baby name to put into a "shopping cart" of some sort?I''m trying to develop an app where the full proposed baby name is kind of built up by the user - i envisage some dragging and dropping to reorder the firstnames - several combinations of "(forname + middle(optional)) + surname" can be reordered to generate the final full name and yes, I can only think that forname and middle name will be necessary. Such a seemingly simple task but when I get to think about it the options for the model seem endless! Also, I don''t want to end up in ruby typing things like this. name = Name.find_by_name("some_name") # seems ridiculous - too many names. grrr, maybe like this. Baby has_many :givennames - gender, string - surname, string GivenName belongs_to :baby - value, string - position, integer #### So then I write stuff like firstname = Baby.first.given_name.first fullname = firstname + " " + Baby.first.surname I''m not sure this all seems a bit clunky and maybe OTT. Not sure how to arrange my models and attribs in this case. Is this approach good/bad/ugly - really welcome some help as I''d like to get the model right 1st off. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Are names generated by the user or do they see a list that *you* have entered into the assumed database? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> So then I write stuff like > > firstname = Baby.first.given_name.first > fullname = firstname + " " + Baby.first.surname >Sorry that code was wrong, I guess it would be something like... firstname = Baby.first.given_name.first.value fullname = firstname + " " + Baby.first.surname ### I don''t like the "value" bit though, and I don''t want to do given_name.name either. Any ideas. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Pale Horse, The names would be generated by the user, they are proposed new baby names. The surname of the baby is of course fixed but needs to be entered, it is that of the parents. Hope that makes sense. Amazing how much there is to think about from a seemingly trivial job! bb -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
bingo bob wrote:> > The names would be generated by the user, they are proposed new baby > names. The surname of the baby is of course fixed but needs to be > entered, it is that of the parents. Hope that makes sense. > > Amazing how much there is to think about from a seemingly trivial job!Indeed, but I think you''re overcomplicating the issue.> bbSo, a simple form with the following fields: Forename, Surname (both stored as strings). *Two* check boxes to determine whether the name is for a male and/or female, and of course a save button. Present this form only after a User has logged in. Now, a ProposedNames table with the following columns: user_id:integer forename:string midname:string surname:string male:tinyint female:tinyint This allows Users to save their proposed names into a database for later retrieval. You can then give the view permission to re-order and alter these names at any time, by displaying a list of proposed names to the User in a secure area. No validation on the column names are necessary, realistically. Unless I''ve misunderstood your request, I don''t see any problems with this approach. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Horseman. Thanks for this. Great. But you can have multiple middle names! Annoying but true Bb -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
bingo bob wrote:> > Horseman. > > Thanks for this. > > Great. > > But you can have multiple middle names!An unlimited amount? In that case, you might consider storing the entered forenames and middles names into separate tables and creating a suggestion tool. I recommend, taking a look at http://railscasts.com/episodes/75-complex-forms-part-3 for adding other fields dynamically. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> An unlimited amount?Well yes, I believe so. In the vast majority of cases people just have firstname surname, also firstname middlename surname. But in essence they could have 100 middle names; although it''s a little unlikely I don''t believe there are legal constraints here in the UK. Pragmatically though - I think I''ll go with a minor adaptation(s) of your first solution.. ProposedNames table with the following columns: user_id :integer forename :string midname1 :string midname2 :string midname3 :string midname4 :string midname5 :string surname :string gender :string Really appreciate your other points re how I might handle the form and logic. Got to love railscasts, I''d be nowhere without them, they are truly excellent. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
bingo bob wrote:>> An unlimited amount? > > Well yes, I believe so. In the vast majority of cases people just have > firstname surname, also firstname middlename surname. But in essence > they could have 100 middle names; although it''s a little unlikely I > don''t believe there are legal constraints here in the UK. > > Pragmatically though - > I think I''ll go with a minor adaptation(s) of your first solution.. > > ProposedNames table with the following columns: > > user_id :integer > forename :string > midname1 :string > midname2 :string > midname3 :string > midname4 :string > midname5 :string > surname :string > gender :string > > Really appreciate your other points re how I might handle the form and > logic. Got to love railscasts, I''d be nowhere without them, they are > truly excellent.I agree with your proposed structure. It would be my recommendation, but you did specify ''unlimited''. It seems *pointless* for a human to have > 7 names. Apologies for omitting the midname column from my original recommendation. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I realised that it''s best to ignore the "one in a million" scenario, and do what works in 99.9% of cases. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
bingo bob wrote:> > I realised that it''s best to ignore the "one in a million" scenario, and > do what works in 99.9% of cases."All that is complex is not useful. All that is useful is simple." As I said in my initial reply, you were overcomplicating it. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Now if we could just stop thinking that the world is composed solely of middle class white anglo saxon males and face the reality. Naming conventions in some cultures go well beyond forename plus surname. Those people also live in the UK. I also note that you are omitting titles and suffixes such as "Queen Elizabeth II" who is also called "Elizabeth Alexandra Mary Windsor". Or even "Hank Williams Jr" or "Hank WIlliams III" or "Sir Robert Geldof" Some people have only one name which is neither a forename or a surname. Lets ignore the artist formerly known a Prince for a moment :) 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). -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Peter Hickman wrote:> > I also note that you are omitting titles and suffixes such as "Queen > Elizabeth II" who is also called "Elizabeth Alexandra Mary Windsor". > Or even "Hank Williams Jr" or "Hank WIlliams III" or "Sir Robert > Geldof" > > Some people have only one name which is neither a forename or a surname. > > Lets ignore the artist formerly known a Prince for a moment :) > > 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).I am *sure* the intended audience of this application would be content with my proposal, but pursuing this argument is a waste of time and resources. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I like Peter Hickman''s answer the best, especially the seperating midname by spaces - doh why didn''t I think of that....really good to bounce this around about, although I''ll probably not bother with the suffixes. Thanks chaps. Yours sincerely, bb aka Sir William Bobby Seadorf Lawrence Elliott Fred-Smith the 2nd -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 29, 12:25 pm, bingo bob <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Appreciate this is a path well travelled probably. > > What''s the best way of to deal with gender. > > i.e. a Person is either Male or Female (generally and fot my purposes > I''ll stick with that rule). > > So is it best to go Person with an attribute gender, or, I guess it''s > best to do something like this - the rails way? > > Person > belongs_to: gender > > Gender > has_many: people > > Sorry if this is such an obvious question just want to do it right.This is a great example of a case where normalization is doing it wrong. Unless you''re somehow expecting additional genders to be added, this sort of a solution is overkill and pretty much only nets you additional database overhead. Using an attribute should suffice... --Matt Jones -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
If it is a "baby name chooser" application then each "name" needs to know whether the name can be "male", "female" or "both." I would create male? and female? as separate fields that can be either true or false. This simplistic approach to design is superior to creating a both option in one field. On Thu, Jul 29, 2010 at 11:03 AM, bingo bob <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Thanks chaps. > > It''s now got me thinking. This stuff is not as easy as it looks. Ive > given up on gender when I realised that a name can belong to both > genders! > > In English my app is a baby name chooser > > A baby can have many proposed names but only one surname. > > A name can be of many types, forename / middlename etc > > Any tips how to model this! > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Peter Hickman wrote:> and treat midname as a space separated list of names (although this > wont handle names like ''st clair'' correctly).Comma separated, then? -- Alan Gutierrez - alan-LPwGgQyxhUi+XT7JhA+gdA@public.gmane.org - http://twitter.com/bigeasy -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 29 July 2010 17:25, bingo bob <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> What''s the best way of to deal with gender. > > i.e. a Person is either Male or Female (generally and fot my purposes > I''ll stick with that rule).I don''t know if it''s annoying anyone else, but I''ve been following this thread with interest, but every time I read "gender" it grates. The word you''re after is "sex". "Male" and "female" are sexes. "Masculine", "feminine", "neutral", etc, are genders... I appreciate that it seems to have become a convention to use the word "gender" as a "polite" reference to the discrimination between innies and outies... but for the vast, overwhelming majority there are only two choices; either being male or female, and that''s your sex (whether it changes over the duration of your life is a different debate :-) Now, I''d store that in a text field in the record as either the full word, or as "m" or "f", and load the DB and the model up with constraints and validations, and not worry about having a Sex model, with associated "sexes" table. Move along to other areas of your application. Regarding the multiple names issue; in response to the suggestion of having multiple name midname fields, I''d ask "why?" What''s the ultimate purpose of storing those names? Generally it''s to just be able to pull them all out of the DB to put on a letterhead when needed, and in that event, you''re optimising too far to give them each a field. For, again, the vast majority of cases, the following will suffice: first_name middle_names last_name (although that assumes the WASP model, which the majority of the world has been forced to adjust it''s naming models to, arguably wrongly as that may have been) If you want to track whether the name "Michael Pavling" should be addressed formally as "Mr Pavling" or as "Michael-san", or whatever, you need to have some way of tracking for each person whether the first_name or the last_name is the "family" name, or I''d consider a "salutation" field which stored that value (even though it duplicates values, breaking normalisation a little). -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling wrote:> On 29 July 2010 17:25, bingo bob <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> What''s the best way of to deal with gender. >> >> i.e. a Person is either Male or Female (generally and fot my purposes >> I''ll stick with that rule). > > I don''t know if it''s annoying anyone else, but I''ve been following > this thread with interest, but every time I read "gender" it grates. > The word you''re after is "sex". > "Male" and "female" are sexes. "Masculine", "feminine", "neutral", > etc, are genders... > > I appreciate that it seems to have become a convention to use the word > "gender" as a "polite" reference to the discrimination between innies > and outies...Not exactly. Sex is biological, gender is psychosocial. There are people of male sex and feminine gender, and vice versa.> but for the vast, overwhelming majority there are only > two choices; either being male or female, and that''s your sex (whether > it changes over the duration of your life is a different debate :-)No. Your sex doesn''t change over the duration of your life if you''re a human (at least, not without surgery, but that''s a different debate). Your gender may. I know genderqueer people who don''t consistently identify with one gender or another, despite whatever genitalia God gave them.> > Now, I''d store that in a text field in the record as either the full > word, or as "m" or "f", and load the DB and the model up with > constraints and validations, and not worry about having a Sex model, > with associated "sexes" table. Move along to other areas of your > application.Agreed if we''re talking about sexes. For genders, there are more than two categories, and the list might change as other gender categories are recognized (yes, the issue is more complex than you''d think), so I''d probably use a model or at least an enumeration for that. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I can''t help but think of the commercial (Visa I think) playing during the world cup where the child had all the names of players on a winning squad from an earlier world cup.... On Jul 30, 6:44 am, bingo bob <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > An unlimited amount? > > Well yes, I believe so. In the vast majority of cases people just have > firstname surname, also firstname middlename surname. But in essence > they could have 100 middle names; although it''s a little unlikely I > don''t believe there are legal constraints here in the UK. > > Pragmatically though - > I think I''ll go with a minor adaptation(s) of your first solution.. > > ProposedNames table with the following columns: > > user_id :integer > forename :string > midname1 :string > midname2 :string > midname3 :string > midname4 :string > midname5 :string > surname :string > gender :string > > Really appreciate your other points re how I might handle the form and > logic. Got to love railscasts, I''d be nowhere without them, they are > truly excellent. > -- > Posted viahttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 30, 6:44 am, bingo bob <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> midname1 :string > midname2 :string > midname3 :string > midname4 :string > midname5 :stringDeignating a particular cardinality just looks kinda wrong to me, tho of course everyone else''s mileage is pretty much guaranteed to vary. How about just midnames? Then you won''t run into problems with typical medieval/Renaissance Spanish names (where they tacked on long lineages), or that guy whose name starts with 128 repetitions of "Shri". :-) Or possibly "midname" and "more_midnames"? Or you could go the other way and separate the name only into family_name and given_names. Question is, is it ever important to have a given specific one of the (given) names? -Dave -- Specialization is for insects. -RAH | Have Pun, Will Babble! -me Programming Blog: http://codosaur.us | Work: http://davearonson.com Leadership Blog: http://dare2xl.com | Play: http://davearonson.net * * * * * WATCH THIS SPACE * * * * * | Ruby: http://mars.groupsite.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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
interestingly enough - that''s exactly what I''ve done. gone with... forename:string midnames:string surname:string midnames seperated by spaces basically, in the vast majority of cases I''d expect 0, 1 or more rarely 2 midnames; pragmatically it just seemed like the right thing to do in this case. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
bingo bob wrote:> interestingly enough - that''s exactly what I''ve done. > > gone with... > > forename:string > midnames:string > surname:string > > midnames seperated by spaces basically, in the vast majority of cases > I''d expect 0, 1 or more rarely 2 midnames; pragmatically it just seemed > like the right thing to do in this case.What you''re doing is most likely going to "work" and will be easy to implement, but your solution is still bad database design. You are relying on a repeating group, multiple values in a single column. It''s fine what you''re doing, as long as you realize that it is bad design and you can live with that. For more details see: http://en.wikipedia.org/wiki/First_normal_form#Repeating_groups -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Aug 4, 2010 at 10:18, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> For more details see: > http://en.wikipedia.org/wiki/First_normal_form#Repeating_groupsI had considered suggesting going with a complete separate table of names, containing a person_id (or in this use-case, fullname_id), sequence number, and string, but that seemed like overkill. It would be "normal", but IMHO HAGNI. :-) -Dave -- Specialization is for insects. -RAH | Have Pun, Will Babble! -me Programming Blog: http://codosaur.us | Work: http://davearonson.com Leadership Blog: http://dare2xl.com | Play: http://davearonson.net * * * * * WATCH THIS SPACE * * * * * | Ruby: http://mars.groupsite.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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Dave Aronson wrote:> On Wed, Aug 4, 2010 at 10:18, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > >> For more details see: >> http://en.wikipedia.org/wiki/First_normal_form#Repeating_groups > > I had considered suggesting going with a complete separate table of > names, containing a person_id (or in this use-case, fullname_id), > sequence number, and string, but that seemed like overkill. It would > be "normal", but IMHO HAGNI. :-)I definitely agree that there are cases where breaking normalization for other gains is desirable. I just don''t completely agree that this is one of those cases. In this case following out to 3NF is beneficial. It would provide for a more flexible and more elegant design. It will also simplify the design for asking more "interesting" questions like, "Give me a list of all names that have Dale as a middle name." Maybe questions like that aren''t a concern now, but breaking normal forms in this case will make questions like that more difficult (and complex) to ask later if the need arises. Why "build in" known limitations when there is no known reasons for do so? I understand the desire for simple design, but not at the cost of good design. Not when there''s no clear reason to avoid the better design. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker wrote:> > I definitely agree that there are cases where breaking normalization for > other gains is desirable. I just don''t completely agree that this is one > of those cases. In this case following out to 3NF is beneficial. It > would provide for a more flexible and more elegant design. It will also > simplify the design for asking more "interesting" questions like, "Give > me a list of all names that have Dale as a middle name." > > Maybe questions like that aren''t a concern now, but breaking normal > forms in this case will make questions like that more difficult (and > complex) to ask later if the need arises. Why "build in" known > limitations when there is no known reasons for do so? > > I understand the desire for simple design, but not at the cost of good > design. Not when there''s no clear reason to avoid the better design.I tend to normalise as often as possible, and I do agree with you Robert. But http://c2.com/cgi/wiki?YouArentGonnaNeedIt also raises a very good point. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Pale Horse wrote:> I tend to normalise as often as possible, and I do agree with you > Robert. But http://c2.com/cgi/wiki?YouArentGonnaNeedIt also raises a > very good point.Given that the primary reason for flattening data, that could otherwise be normalized, is for performance optimization reasons, http://c2.com/cgi/wiki?PrematureOptimization is the balance to YAGNI. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker wrote:> > Pale Horse wrote: >> I tend to normalise as often as possible, and I do agree with you >> Robert. But http://c2.com/cgi/wiki?YouArentGonnaNeedIt also raises a >> very good point. > > Given that the primary reason for flattening data, that could otherwise > be normalized, is for performance optimization reasons, > http://c2.com/cgi/wiki?PrematureOptimization is the balance to YAGNI.Tautological, is this matter. Normalising the database *is* indeed, almost always the correct methodology. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.