If you want to know how many sales were made to a give client (e.g. where IDclie = 
99), this should see you right:

SELECT count(*)
FROM Sale, Basket
WHERE Sale.idbask = Basket.IDbask
    AND Basket.IDClie = 99

Paul Vincent
DBA
University of Central England

-----Original Message-----
From: RuiSMonteiro [mailto:[EMAIL PROTECTED]
Sent: 27 July 2004 09:44
To: [EMAIL PROTECTED]
Subject: MySQL table design


Hello,

I'll try to explain correctly my idea.

I need to develop a on-line sale's website. For that, I have some dough's on how to 
create the table "basket".

Client

 - IDclie (PK)
 - ...

Produts

 - IDprod (PK)
 - ...

Basket

 - IDbask (PK)
 - IDprod (FK)
 - IDClie (FK)
 - qt
 - date

Sale

 - IDsale (PK)
 - idbask (FK) -> there should only be one ID per basket...in this case.
 - shipping_debit
 - ...

I dont know how to make a propper relation when it comes to (Client - Basket), because 
I wanted to know how many sales a client made.

I was thinking on making an extra table by removing IDclie from Basket and making this:

Clie/Basket
 
 - IDclie (PK)
 - IDbask (PK)

But I can't really add any values due to foreign key constraints.

Any help on how to resolve my problem? How should I solve this?


Thanks

 

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to