Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Testing Conditions to set status on the fly

Posted on 2012-12-26
6
Medium Priority
?
177 Views
Last Modified: 2012-12-26
I have a table that holds orders.  One order can take up multiple rows, and each item can have its own status within an order.

What I'm trying to do is figure out a way to look at each row, and if all the status' equal 1 to code the order status as 'Placed'  If there are two items marked as shipped but one as placed, the order status would be In Progress.  Similarly, if all item status' equal Shipped, then the whole order is marked as shipped.

Not sure where to start on this.
0
Comment
Question by:t3chguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 38721833
I'm fairly certain the right place to start is to make a Google search for this exact set of search terms and begin by reading the thoughtful arguments on both sides of the issue:
Should I Normalize My Database
A normalized data base will not have data structures that lead to ambiguity or that "where do I start" feeling, I promise!
0
 
LVL 1

Author Comment

by:t3chguy
ID: 38721841
So you're saying that my the way I've structured the data is not good?  How could it be better organized?
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 38721908
This is just a quick guess (you really need a DBA to advise you).  No order would take up more than one row -- that is the canonical element and it should have a row of its own.  The table of orders would have a separate junction table that joined each order to the items within the order, and a separate junction table that joined the items to shipping and payment status, etc.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:t3chguy
ID: 38721921
Thanks, Ray, sometimes, I think taking shortcuts and adding tables isn't always the best solution, but in reading more and more about normalization and understanding your flow from your previous post, I'm starting to see that that is not always the case.

I'm going to restructure my table and have the following structure:

mk_indiv_orders
mk_indiv_items

So knowing that now, would it be better to help answer my initial question regarding checking each item status and from that updating the overall order status?
0
 
LVL 22

Accepted Solution

by:
Kim Walker earned 2000 total points
ID: 38722116
Is it safe to say that there are only two values for the status of an individual item, placed or shipped? If that is true, you could use the DISTINCT modifier to select the distinct values for the status of all the items in the order. If your query result has two rows, then some items are placed and others are shipped and the order is "in progress." But if all the items are placed or all the items are shipped, only one row would be returned and the order status could take on that one distinct status.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 38722510
Glad you found a solution.  Sorry I couldn't help further, but I went to see the movie Django with my son, and it was voted Excellent by two generations!  Best regards and Happy New Year 2013, ~Ray
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question