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

  • SEARCH
  • Home
  • 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 8101957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:06:55+00:00 2026-06-05T23:06:55+00:00

I am working on a iPad ordering web app at the moment which consists

  • 0

I am working on a iPad ordering web app at the moment which consists of different pieces of clothing. The linesheet will be built like this:

20-30 different product will be shown in the same form. Every product have five different sizes to choose from and every size has a different quantity depending on what the buyer would like to order.

I have a products table with the following columns:

id
product_number  
product_name    
product_size    
product_color   
product_description     
product_image   
product_title   
product_category    
product_composition     
product_price_wholesale_dkk     
product_price_wholesale_eur     
product_price_retail_dkk    
product_price_retail_eur    
product_active  
product_detail_one  
product_detail_two  
product_detail_three    
product_xsmall  (activate size for this product? is it avail.)
product_small (activate size for this product? is it avail.)
product_medium (activate size for this product? is it avail.)
product_large (activate size for this product? is it avail.)
product_xlarge (activate size for this product? is it avail.)

and an orders table with the following columns:

id 
order_store 
order_reference 
order_mail 
order_payment_details 
order_products 
order_value_total_wholesale_dkk 
order_value_total_retail_dkk 
order_value_total_wholesale_eur 
order_value_total_retail_eur 
order_date 
order_phone 
order_VAT 
order_address 
order_comments 
order_product_numbers 
order_product_pieces 
order_store_country

My problem is that I can’t figure out how the database should be set up. When the order confirmation is sent to the buyer every product should be listed with the specific number of sizes for every product, and since every size might or might not be selected it needs to identify which ones has been chosen and how many of the particular size for the particular product.

How will I be able to make the system check first of all which sizes for the specific product has been ordered and then next how many of that size (database wise) and then PHP wise when choosing the tables in my script?

Thanks in advance.

  • 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. Editorial Team
    Editorial Team
    2026-06-05T23:06:57+00:00Added an answer on June 5, 2026 at 11:06 pm

    It might help to look at the issue by way of associations. An order has many products, while a product has one order. From there you can discern which fields should be your foreign keys. If you decided to use an ORM (good SO discussion), it will make interacting with the aforementioned associations easier but there is the learning curve associated with the ORM.

    As far as selecting a size goes, you may want to keep a third "lookup" table with just size information in it. For instance, have a table with id and size where id is the row id and size is "sm", "med", "large", etc. From there, have a product size column that you would have an id to a size. You may also want to have a table that associates an ordered item with an order. So you would have a table with id (of course), order_id, product_id, count, and, if it makes sense to store a size for every item ordered, size. That way you could store the size of each ordered item and know which items in an order were set and which were not with a query like: SELECT product_id from ordered_items WHERE size = '' AND order_id = ?. Assuming MySQL (or SQLite3 I believe), that query would return all ordered items with an order id of ? (whatever your criteria is), the count ordered, and no set size. You would of course want to set the ordered_items size column to be nullable.

    Sorry for the rambling answer, if any of that is not clear, let me know and I will refine it where necessary.

    Update:

    While editing my answer, Luke Pittman fleshed out the model/schema for the table I attempted to explain.

    Update 2:

    In response to your comment below: I have never used sqlite3 on IOS but, from this post with an example sqlite3 IOS 5 application, it appears that after you set up the database connection, you just issue straight sqlite commands. So the create table command for ordered_items could look something like this:

    CREATE TABLE ordered_items(
        id         INTEGER PRIMARY KEY,
        order_id   INTEGER NOT NULL,
        product_id INTEGER NOT NULL,
        quantity   INTEGER DEFAULT 0,
        size       TEXT,
        price      NUMERIC, DEFAULT 0.0,
        updated    DATETIME NOT NULL,
        created    DATETIME DEFAULT current_timestamp
        FOREIGN KEY(order_id) REFERENCES orders(id)
        FOREIGN KEY(product_id) REFERENCES products(id)
    )
    

    Or if you have a size table that has an id and size, you could add another foreign key to the size table by changing the size column to: size_id INTEGER and add the FK with: FOREIGN KEY(size_id) REFERENCES sizes(id).

    Note:

    You will want to read up on SQLite3 Foreign Key Constraints such as section 4.3 ON UPDATE and ON DELETE. These constraints can help keep your data in sync so that, if for instance you deleted a product but had existing order_items referencing that product_id, it could delete them or set them to some default. You may or may not want that depending on your purposes, but it is a good idea to be familiar with foreign keys and their available constraints.

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

Sidebar

Related Questions

I am working on an iPad app (which will not be submitted to the
I'm working on an iPad app that downloads a CSV file from the web
I am working on an iPad app which has an embedded HTTP server listening
I'm working on a iPad app that is mainly a web view. It is
I'm working on an ipad app which is meant to have several UIWebView controls
I am working on an iPad app (iOS 5 ARC) that will show threads
I'm working on an iPad app which has a UISplitView . The root view
I am working on an iPad app. I have a viewcontroller which I want
I am working on an iPad app that seems like a natural fit for
I'm working on an iPad app in Monotouch (5.2.12). The app will be used

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.