Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: input form and MySQL across columns

by jandrew (Chaplain)
on Sep 02, 2012 at 22:51 UTC ( #991335=note: print w/replies, xml ) Need Help??

in reply to input form and MySQL across columns

I'm not entirely sure I follow your problem but I would say that the issue seems to fall in the set up of your MySQL table

The columns qty1, qty2, qty3, and qty4 break the Repeating groups across columns restriction of the "first normal form" of relational data bases

If you accept that this is the problem the fix would be a table that looked something like

ID type name qty_position qty status 1 Group1 Shoes 1 15 ok 2 Group1 Shoes 2 50 ok

This solution gets you back to a query with return values in one column. You just have to use conditions on more than one column to SELECT the right data.

A word of warning - distributing the status column across all of the rows effectively breaks another of the normal form rules. To fix it you would move that value to a separate table. However, If the status is defined at the point of the transaction for each quantity increment then you are fixing something rather than breaking it.

Replies are listed 'Best First'.
Re^2: input form and MySQL across columns
by Anonymous Monk on Sep 03, 2012 at 00:51 UTC
    Thanks for the reply, I agree the table should probably have been structured in a single column right from the beginning. I was hoping to come up with a solution without having to go down that path. And good point on the status column as well. I'll wait until the other Monks reply before I redo the table, I have quite a bit of code already written for inserting and updating the table that works quite well.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991335]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2018-12-16 10:52 GMT
Find Nodes?
    Voting Booth?
    How many stories does it take before you've heard them all?

    Results (70 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!