Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 12th, 2003, 09:58 PM
Authorized User
 
Join Date: Oct 2003
Location: KL, wilayah persekutuan, Malaysia.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default mysql discount table

my tables are as below.
CREATE TABLE PRODUCT
(
    PROD_ID VARCHAR(5) NOT NULL,
    PROD_NAME VARCHAR(20) NOT NULL,
    PROD_DESC VARCHAR(20) NOT NULL,
    PROD_PRICE DECIMAL NOT NULL,
    PROD_CAT INT NOT NULL,
    PRIMARY KEY(PROD_ID),
    FOREIGN KEY(PROD_CAT) REFERENCES CATEGORY,
);
CREATE TABLE SALES
(
    SALES_ID INT NOT NULL,
    SALES_DATE DATE NOT NULL,
    CUST_ID VARCHAR(5) NOT NULL,
    EMP_ID VARCHAR(6) NOT NULL,
    PRIMARY KEY(SALES_ID),
    FOREIGN KEY (CUST_ID) REFERENCES CUSTOMER,
    FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE,
);

CREATE TABLE SALES_DETAIL
(
    SALES_ID INT NOT NULL,
    PROD_ID VARCHAR(5) NOT NULL,
    QUANTITY INT NOT NULL,
    PRIMARY KEY (SALES_ID, PROD_ID),
);

if some of the product have discount for a duration of some time, should i create a product table?
CREATE TABLE DISCOUNT
(
    DISCOUNT_ID INT NOT NULL,
    PROD_ID VARCHAR(5) NOT NULL,
    START_DATE DATE NOT NULL,
    END_DATE DATE NOT NULL,
);

This is my sql queries without the discount table. if the discount table is created, how am i going to make changes to the query to count the total after deducted the discount?

select month(s.sales_date), s.cust_id, sum((p.prod_price * sd.quantity)) as Total
from product p, sales_detail sd, sales s, category c
where sd.sales_id=s.sales_id and p.prod_id=sd.prod_id and c.category_id=p.prod_cat and year(s.sales_date) = '1999'
group by month(s.sales_date), s.cust_id;



Closed Thread


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Applying discount blkskullwork Javascript 1 January 11th, 2007 04:14 PM
Discount For P2P Members? anand_thakur Forum and Wrox.com Feedback 0 January 28th, 2005 08:05 AM
mysql table hosefo81 PHP Databases 1 February 20th, 2004 03:09 PM
Discount dannomite Wrox Book Feedback 3 June 5th, 2003 10:09 AM



All times are GMT -4. The time now is 07:07 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.