Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 119243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:37:20+00:00 2026-05-11T03:37:20+00:00

I have a small project I am doing in Python using web.py. It’s a

  • 0

I have a small project I am doing in Python using web.py. It’s a name generator, using 4 ‘parts’ of a name (firstname, middlename, anothername, surname). Each part of the name is a collection of entites in a MySQL databse (name_part (id, part, type_id), and name_part_type (id, description)). Basic stuff, I guess.

My generator picks a random entry of each ‘type’, and assembles a comical name. Right now, I am using select * from name_part where type_id=[something] order by rand() limit 1 to select a random entry of each type (so I also have 4 queries that run per pageview, I figured this was better than one fat query returning potentially hundreds of rows; if you have a suggestion for how to pull this off in one query w/o a sproc I’ll listen).

Obviously I want to make this more random. Actually, I want to give it better coverage, not necessarily randomness. I want to make sure it’s using as many possibilities as possible. That’s what I am asking in this question, what sorts of strategies can I use to give coverage over a large random sample?

My idea, is to implement a counter column on each name_part, and increment it each time I use it. I would need some logic to then say like: ‘get a name_part that is less than the highest ‘counter’ for this ‘name_part_type’, unless there are none then pick a random one’. I am not very good at SQL, is this kind of logic even possible? The only way I can think to do this would require up to 3 or 4 queries for each part of the name (so up to 12 queries per pageview).

Can I get some input on my logic here? Am I overthinking it? This actually sounds ideal for a stored procedure… but can you guys at least help me solve how to do it without a sproc? (I don’t know if I can even use a sproc with the built-in database stuff of web.py).

I hope this isn’t terribly dumb but thanks ahead of time.

edit: Aside from my specific problem I am still curious if there are any alternate strategies I can use that may be better.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:37:21+00:00Added an answer on May 11, 2026 at 3:37 am

    I think what you’re after is:

    select * from name_part     where type_id=[something]     order by used_count asc, rand()     limit 1 

    This will put the lesser used names at the top of the list and, if there’s multiples with the same (lowest) used_count, they’ll sort randomly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 95k
  • Answers 95k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Actually you can define whatever you want to be a… May 11, 2026 at 6:59 pm
  • Editorial Team
    Editorial Team added an answer You are confusing a perfect binary tree with a full… May 11, 2026 at 6:59 pm
  • Editorial Team
    Editorial Team added an answer You can try EE Open ID. There is currently not… May 11, 2026 at 6:59 pm

Related Questions

I have a small project I am doing in Python using web.py. It's a
Summary I recently had a conversation with the creator of a framework that one
I am doing a CSV Import tool for the project I'm working on. The
My studio has a large codebase that has been developed over 10+ years. The
I'm working on a small app where I can generate a list of barcodes.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.