MySQL supports using InnoDB tables.

CREATE TABLE customers (
num INT PRIMARY KEY,
Name VARCHAR(50) NOT NULL);

CREATE TABLE sales(
Product VARCHAR(15) NOT NULL,
Price DOUBLE NOT NULL,
Cust INT NOT NULL,
# PRIMARY KEY definition goes here,
INDEX (Cust),
FOREIGN KEY(Cust) REFERENCES customers(num) ON DELETE RESTRICT ON UPDATE
CASCADE);

Now if the "num" changes in customer, MySQL automatically updates "Cust"
on SALES.

Adolfo

> -----Original Message-----
> From: David T-G [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, December 03, 2002 5:36 PM
> To: mysql users
> Subject: relational is relational is relational, but ...
>   +------------------------+             +------------------------+
>   | SALES                  |             | CUSTOMERS              |
>   +---------+-------+------+             +------+-----------------+
>   | product | price | cust |             | num  | name            |
>   +---------+-------+------+             +------+-----------------+
>   | TXLblue | 14.99 | 1136 |             | 1136 | richard roe     |
>   +---------+-------+------+             +------+-----------------+
>   | CMMblck | 11.50 | 2408 |             | 2408 | jane doe        |
>   +---------+-------+------+             +------+-----------------+
>   | SMMblue | 22.75 | 2408 |             | 8421 | bob smith       |
>   +---------+-------+------+             +------+-----------------+
> 
> where SALES.cust gets filled with the same value as 
> CUSTOMERS.num -- but should the customer number somehow 
> change we're now out of sync, whereas in a truly relational 
> database the fields in the SALES.cust column would
> *be* the fields in the CUSTOMERS.num column rather than 
> simply having the same value.
> 
> Am I lost, out of my tree, confused, or bang on?  And how 
> (perhaps InnoDB
> tables) does MySQL support this if I'm not any of the first three?
> 
> 
> TIA & HAND
> 
> mysql query,
> :-D
> - -- 
> David T-G                      * There is too much animal courage in 
> (play) [EMAIL PROTECTED] * society and not sufficient 
> moral courage.
> (work) [EMAIL PROTECTED]  -- Mary Baker Eddy, 
> "Science and Health"
> http://www.justpickone.org/davidtg/    Shpx gur 
> Pbzzhavpngvbaf Qrprapl Npg!
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.7 (FreeBSD)
> 
> iD8DBQE97SO3Gb7uCXufRwARAooDAKDI6dhugjyejLAEwC5Sjl6Pjqz/nACcDoj0
> vUcEuhNZHvTYh+KjGz05/9Q=
> =hZrX
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail 
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 
> 
> 
> 


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to