Avatar of rmmarsh
rmmarsh
Flag for United States of America asked on

Need some design help with SQLite...

I'm trying to create a SQLite database consisting of two tables: Customer and Order.   This is what I have so far for the Customer table:

        [db executeUpdate:@"CREATE TABLE IF NOT EXISTS CustData ("
         "BUS_NAME TEXT PRIMARY KEY NOT NULL, "
         "EMAIL TEXT, "
         "PHONE TEXT, "
         "SHOP_NAME TEXT, "
         "SHOP_ADDR1 TEXT, "
         "SHOP_ADDR2 TEXT, "
         "SHOP_CITY_STATE TEXT, "
         "SHOP_ZIP TEXT, "
         "SHIP_NAME TEXT, "
         "SHIP_ADDR1 TEXT, "
         "SHIP_ADDR2 TEXT, "
         "SHIP_CITY_STATE TEXT, "
         "SHIP_ZIP TEXT, "
         "NOTES TEXT)"];

Open in new window


This what I have for my Order table:

        [db executeUpdate:@"CREATE TABLE Orders ("
         "CUST_ID TEXT REFERENCES CustData, "
         "ORDER_NBR TEXT, "
         "SALES_NAME TEXT, "
         "CREDIT_CARD TEXT, "
         "EXP_DATE TEXT, "
         "CID TEXT, "
         "NOTES TEXT, "
         "PCS INTEGER, "
         "PATTERN TEXT, "
         "STYLE_NAME TEXT, "
         "PRICE DECIMAL)" ];

Open in new window


My questions are:
Is the "references" statement correct?  I want to have each order reference the key in the Customer table
PCS, pattern, style_name and PRICE will occur many times for each "order".  Is this the correct way to define them in the Order table, or is there a better way?
Databases.NET ProgrammingC#

Avatar of undefined
Last Comment
rmmarsh

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Anuradha Goli

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
rmmarsh

ASKER
Thank you... I appreciate it!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy