Lookup scheme for a database (question)

2 views
Skip to first unread message

Travis Smith

unread,
Mar 2, 2017, 6:04:02 PM3/2/17
to omg-...@googlegroups.com
Hey guys,

Feel free to tell me to keep digging on StackOverflow, but I'm having a hard time with this one:

- I want to store info in a database (SQL, most likely)
- I want the lookup to be a unique identifier that corresponds with the results of a series of input questions for the user. 

If the exact inputs (4-12 questions) have been put in previously, I'd like to just return the pre-computed and stored results from the database.

else I want to perform the computation and store the results under a new unique identifier.

- So, I guess what I'm after is a way to convert my user's initial specs with a number.  I thought I might be able to do this with a hash, but initial results are not promising.  I'm seeing that the hashes might be entirely different depending on the machine that runs it, which wouldn't meet the goal.

Thanks in advance,

Travis

GPG Key: BFEB 7E65 04EB 184B A150 2E2C CC11 933F EE27 D86E

David Knaack

unread,
Mar 2, 2017, 7:27:11 PM3/2/17
to omg-...@googlegroups.com
You can use a composite primary key on your table. Each column goes with a specific question, so when you query the database you will get the matching row. No need to convert the input to a number, though you might need to sanitize or standardize it a bit. The key guarantees that you will have only one matching row. It doesn't have to be the primary key, a unique index will work too. Doesn't work as well if.you don't have values for all of the fields, but there are other options too.

--
OMG!Code http://code.omahamakergroup.org
---
You received this message because you are subscribed to the Google Groups "OMG!Code" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/omg-code.
For more options, visit https://groups.google.com/d/optout.

Kevin Fusselman

unread,
Mar 2, 2017, 7:36:36 PM3/2/17
to omg-...@googlegroups.com
Data standardization, depending on the type of questions would be key.  If the inputs are free-text the exercise gets quite a bit harder... I actually had to explain to a user once that I couldn't group by a free-text field...

To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+u...@googlegroups.com.

--
OMG!Code http://code.omahamakergroup.org
---
You received this message because you are subscribed to the Google Groups "OMG!Code" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+u...@googlegroups.com.

Travis Smith

unread,
Mar 3, 2017, 7:29:25 PM3/3/17
to omg-...@googlegroups.com
Thanks guys.  Still working on it, but this helped considerably.

Travis

GPG Key: BFEB 7E65 04EB 184B A150 2E2C CC11 933F EE27 D86E

On Thu, Mar 2, 2017 at 6:36 PM, Kevin Fusselman <ke...@fusselman.org> wrote:
Data standardization, depending on the type of questions would be key.  If the inputs are free-text the exercise gets quite a bit harder... I actually had to explain to a user once that I couldn't group by a free-text field...
On Thu, Mar 2, 2017 at 6:27 PM David Knaack <david...@gmail.com> wrote:
You can use a composite primary key on your table. Each column goes with a specific question, so when you query the database you will get the matching row. No need to convert the input to a number, though you might need to sanitize or standardize it a bit. The key guarantees that you will have only one matching row. It doesn't have to be the primary key, a unique index will work too. Doesn't work as well if.you don't have values for all of the fields, but there are other options too.
On Mar 2, 2017 5:04 PM, "Travis Smith" <trav...@gmail.com> wrote:
Hey guys,

Feel free to tell me to keep digging on StackOverflow, but I'm having a hard time with this one:

- I want to store info in a database (SQL, most likely)
- I want the lookup to be a unique identifier that corresponds with the results of a series of input questions for the user. 

If the exact inputs (4-12 questions) have been put in previously, I'd like to just return the pre-computed and stored results from the database.

else I want to perform the computation and store the results under a new unique identifier.

- So, I guess what I'm after is a way to convert my user's initial specs with a number.  I thought I might be able to do this with a hash, but initial results are not promising.  I'm seeing that the hashes might be entirely different depending on the machine that runs it, which wouldn't meet the goal.

Thanks in advance,

Travis

GPG Key: BFEB 7E65 04EB 184B A150 2E2C CC11 933F EE27 D86E

--
OMG!Code http://code.omahamakergroup.org
---
You received this message because you are subscribed to the Google Groups "OMG!Code" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+unsubscribe@googlegroups.com.

--
OMG!Code http://code.omahamakergroup.org
---
You received this message because you are subscribed to the Google Groups "OMG!Code" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+unsubscribe@googlegroups.com.

--
OMG!Code http://code.omahamakergroup.org
---
You received this message because you are subscribed to the Google Groups "OMG!Code" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+unsubscribe@googlegroups.com.

Chris Miller

unread,
Mar 7, 2017, 9:31:43 AM3/7/17
to OMG!Code
I'm confused. We use hashing algorithms throughout the tech industry to insure, for example, that code you download hasn't been tampered with or a file isn't damaged in transmission. If hash values change depending on the machine it is generated on there is something seriously broken in either the algorithm or the process. Any hashing algorithm consistently applied to the same data should always produce the same value no matter what the platform. That said, computing a hash probably is at least as cpu intensive and computing the result you are trying to avoid having to compute in the first place so if the idea is to save some cpu cycles then using the values themselves as part of a composite key like David suggests would be most efficient. You might even be able to string them together to have a single column primary key.

Jay Hannah

unread,
Mar 7, 2017, 10:45:28 AM3/7/17
to omg-...@googlegroups.com
On Mar 7, 2017, at 8:31 AM, Chris Miller <cami...@gmail.com> wrote:
> computing a hash probably is at least as cpu intensive and computing the result you are trying to avoid having to compute in the first place

I assumed calculating his result involved something enormously expensive. Like dispatching carrier pigeons or something. :)

If not then I don't understand why he would want a cache at all.

j



Travis Smith

unread,
Mar 7, 2017, 6:35:57 PM3/7/17
to omg-...@googlegroups.com
They are expensive calculations, yes. I suspect that the final product might take 10-20 seconds to finish an entry, so I'd rather store pre-computed answers.

It's also the case that I've never actually implemented a database before, or written a program (other than longish scripts). This project is a bit of a crash course in several areas at once. Each new problem is a process of discovery. Yesterday I was learning a bit about how to space my code out into several files, and how a directory structure correlates to module imports.

But, I understand that coder brain calculations are also expensive. Maybe I could ask questions at a future OMG code session, or the next OMG meeting.

Python 3.5, if you were wondering!

-Travis
> --
> OMG!Code http://code.omahamakergroup.org
> ---
> You received this message because you are subscribed to the Google Groups "OMG!Code" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+u...@googlegroups.com.

Travis Smith

unread,
Mar 10, 2017, 9:02:24 AM3/10/17
to omg-...@googlegroups.com
With that said...does anyone else see an excuse for a meeting?  I'd like to rap.  If that's impossible, I guess I'll just keep posting.

Travis

GPG Key: BFEB 7E65 04EB 184B A150 2E2C CC11 933F EE27 D86E

> To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+unsubscribe@googlegroups.com.

David Knaack

unread,
Mar 11, 2017, 12:40:51 PM3/11/17
to omg-...@googlegroups.com
I'd be up for a meeting.

Jay Hannah

unread,
Mar 11, 2017, 1:26:59 PM3/11/17
to omg-...@googlegroups.com
For years I think I drove the date selection process, but I stopped since I'm out of town for months at a time nowadays. I'd love to show up for dates other people declare. :)

I was sick this week, but I usually join the gang at Accelerando Coffee House on Wednesdays

https://twitter.com/omahacoworking

And Do Space on Fridays. :)

j



> On Mar 11, 2017, at 11:40 AM, David Knaack <david...@gmail.com> wrote:
>
> I'd be up for a meeting.
>
> On Fri, Mar 10, 2017 at 8:01 AM, Travis Smith <trav...@gmail.com> wrote:
> With that said...does anyone else see an excuse for a meeting? I'd like to rap. If that's impossible, I guess I'll just keep posting.
>
> Travis
>
> GPG Key: BFEB 7E65 04EB 184B A150 2E2C CC11 933F EE27 D86E
>
> On Tue, Mar 7, 2017 at 5:35 PM, Travis Smith <trav...@gmail.com> wrote:
> They are expensive calculations, yes. I suspect that the final product might take 10-20 seconds to finish an entry, so I'd rather store pre-computed answers.
>
> It's also the case that I've never actually implemented a database before, or written a program (other than longish scripts). This project is a bit of a crash course in several areas at once. Each new problem is a process of discovery. Yesterday I was learning a bit about how to space my code out into several files, and how a directory structure correlates to module imports.
>
> But, I understand that coder brain calculations are also expensive. Maybe I could ask questions at a future OMG code session, or the next OMG meeting.
>
> Python 3.5, if you were wondering!
>
> -Travis
>
> > On Mar 7, 2017, at 9:45, Jay Hannah <j...@jays.net> wrote:
> >
> >> On Mar 7, 2017, at 8:31 AM, Chris Miller <cami...@gmail.com> wrote:
> >> computing a hash probably is at least as cpu intensive and computing the result you are trying to avoid having to compute in the first place
> >
> > I assumed calculating his result involved something enormously expensive. Like dispatching carrier pigeons or something. :)
> >
> > If not then I don't understand why he would want a cache at all.
> >
> > j
> >
> >
> >
> > --
> > OMG!Code http://code.omahamakergroup.org
> > ---
> > You received this message because you are subscribed to the Google Groups "OMG!Code" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+u...@googlegroups.com.
> > Visit this group at https://groups.google.com/group/omg-code.
> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
> OMG!Code http://code.omahamakergroup.org
> ---
> You received this message because you are subscribed to the Google Groups "OMG!Code" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+u...@googlegroups.com.
> Visit this group at https://groups.google.com/group/omg-code.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> OMG!Code http://code.omahamakergroup.org
> ---
> You received this message because you are subscribed to the Google Groups "OMG!Code" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+u...@googlegroups.com.

Travis Smith

unread,
Mar 15, 2017, 4:22:11 PM3/15/17
to omg-...@googlegroups.com
I couldn't see what times Omaha co-working meets.  Is it just business hours?  I'm only able to make nights/weekends, but it does look like a good initiative.

Travis

GPG Key: BFEB 7E65 04EB 184B A150 2E2C CC11 933F EE27 D86E

> > To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+unsubscribe@googlegroups.com.

> > Visit this group at https://groups.google.com/group/omg-code.
> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
> OMG!Code http://code.omahamakergroup.org
> ---
> You received this message because you are subscribed to the Google Groups "OMG!Code" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/omg-code.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> OMG!Code http://code.omahamakergroup.org
> ---
> You received this message because you are subscribed to the Google Groups "OMG!Code" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/omg-code.
> For more options, visit https://groups.google.com/d/optout.

--
OMG!Code http://code.omahamakergroup.org
---
You received this message because you are subscribed to the Google Groups "OMG!Code" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omg-code+unsubscribe@googlegroups.com.

Jay Hannah

unread,
Mar 16, 2017, 9:41:24 AM3/16/17
to omg-...@googlegroups.com
Re: https://twitter.com/omahacoworking

On Mar 15, 2017, at 3:21 PM, Travis Smith <trav...@gmail.com> wrote:
> I couldn't see what times Omaha co-working meets. Is it just business hours? I'm only able to make nights/weekends, but it does look like a good initiative.

Ah. Ya, it's very unstructured.

It's mostly a bunch of 9-5 telecommuters wanting to get out of the house once a twice a week.

Broadly on Wednesdays there are ~6 people at Accelerando Coffee House 9-5, and Do Space on Fridays 9-5.

j



Travis Smith

unread,
Mar 16, 2017, 10:02:12 PM3/16/17
to omg-...@googlegroups.com
In the best way possible, I envy you the telecommute.  My way of life has its own advantages, but not that one yet.

Travis

GPG Key: BFEB 7E65 04EB 184B A150 2E2C CC11 933F EE27 D86E


j



Reply all
Reply to author
Forward
0 new messages