Author Topic: Random Name and Character Skills Table Questions  (Read 1059 times)

Offline dbest

  • Game Owner
  • Level 20
  • *
  • Posts: 211
  • Reputation: +3/-0
    • View Profile
    • Tennis Masters
Random Name and Character Skills Table Questions
« on: July 07, 2011, 01:36:17 PM »
Yeah... just to let you guys know, am back to working on a game.

Random Name
I was about to begin coding the random name generator and had a question. The last time I used names stored in an array. This time around, I would prefer to store the first name/last name combination in a db. I also need to store the country from which the names are from.
So should I have 2 tables:

FirstName
----------
Nat -> nationality
firstName -> self explanatory, I hope

and the second one for the LastName. Then I could select 2 random names and match them to generate a Character Name.
Is there any other optimal way to go about it?

Character Skills
There will be roughly 2000 plus characters in the game. Each character has some attributes including name, age, etc. A character also has roughly 20 skills. The skills can be improved over time.
The question that I have is whether I should have a separate table for the character skills or have all the character attributes in one table?

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
Re: Random Name and Character Skills Table Questions
« Reply #1 on: July 07, 2011, 07:09:45 PM »
I'd do it in two tables. I'd also make 'nationality' a single tinyint column. That way you can use an index for sorting(to help speed up selects), also it'd help since you'd be able to have more nationalities later. I don't know of any other way to do two tables for you to use. Unless you did one table and did it as follows.

names(
name_id int unsigned not null,
nationality tinyint unsigned not null,
name varchar(50) not null,
name_type tinyint(1) not null,
primary key(name_id),
index(nationality)
)engine=innodb;

And then you'd do a select where name_type =0 and one where name_type=1 at some position. You could either do the picking in mysql(via a limit of 1 and some offset), or you could do it in php the normal way. Anyway that's how i'd do it as both ways that I can think of.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Random Name and Character Skills Table Questions
« Reply #2 on: July 07, 2011, 07:24:13 PM »
Why do you need to use DB for random names? Generation of these should be extremely rare in a typical game, so optimization here is irrelevant. Just use plain txt/ini/xml files (much easier to modify - you can send these to other people to fill with content).

Skills - definitely all in one table.

Offline dbest

  • Game Owner
  • Level 20
  • *
  • Posts: 211
  • Reputation: +3/-0
    • View Profile
    • Tennis Masters
Re: Random Name and Character Skills Table Questions
« Reply #3 on: July 08, 2011, 02:18:49 AM »
Thanks 133794m3r. I think that's a better solution than mine.

@Chris - Well, there would be 40 characters per squad. Each country would roughly have 50 squads. There might be at least 4 countries. So that's why I need random names to be generated. I do agree that this is a one-off activity.
Thanks for your feedback on the skills.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Random Name and Character Skills Table Questions
« Reply #4 on: July 08, 2011, 02:55:53 AM »
If you need it one time why not use preexising generator? Like that one: http://www.fakenamegenerator.com/advanced.php?n[]=pl&c[]=ca&x=48&y=5&gen=0&age-min=19&age-max=85

If you insist on making it yourself do not forget that in most languages female last name will be slightly different than husband's last name due to gender (English doesn't have gender). So, you need both male name+surname and female name+surname (4 tables).
(example of broken generator: http://www.behindthename.com/random/ don't use it!)

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
Re: Random Name and Character Skills Table Questions
« Reply #5 on: July 08, 2011, 03:07:41 AM »
If you need it one time why not use preexising generator? Like that one: http://www.fakenamegenerator.com/advanced.php?n[]=pl&c[]=ca&x=48&y=5&gen=0&age-min=19&age-max=85

If you insist on making it yourself do not forget that in most languages female last name will be slightly different than husband's last name due to gender (English doesn't have gender). So, you need both male name+surname and female name+surname (4 tables).
(example of broken generator: http://www.behindthename.com/random/ don't use it!)
Why would you need 4 tables? Add a single tinyint column. 1 byte vs 4bytes for the primary index. Add a gender tinyint column. It's extremely simple. And using an existing generator might not be something that he wants to do. If he does, hten I'd tell him to go right on for it. Since it's already done.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal