Re: [PHP-DB] MySQL Foreign Key Issue

2007-03-27 Thread OKi98

Luchino - Samel wrote:


*Question No. 01*
there are some kind of foreign key in database
Some of them want give any error when you delete from the table where the
foreign key is in, this cause the remove is recursive and it delete 
also

the ORDER linked to the CUSTOMER (CASCADE foreign key).
In other kind of foreign key (I don't remember the name) you cannot 
delete

CUSTOMER if there is some ORDER linked to them.


restrict


hope this will help

c-ya



2007/3/26, Lasitha Alawatta [EMAIL PROTECTED]:



 Hello,



I have 2 issue, regarding MySQL Foreign Key.

I have two tables;

Table 01 *CUSTOMER*

column name

characteristic

SID

Primary Key

Full_Name





Table *ORDERS*

column name

characteristic

Order_ID

Primary Key

Order_Date



Customer_SID

Foreign Key

Amount





When I run ALTER TABLE ORDERS ADD FOREIGN KEY (customer_sid) REFERENCES
CUSTOMER(SID); that sql statement,



I inserted 2 records to both tables.

* *

*Question No. 01.*

Then I removed 1 record from CUSTOMER table. But It want give any error
message. It should give an error message, because in ORDERS table 
already
have some records relevant to the deleted customer record in CUSTOMER 
table.


you have restrict constraint on Customer_SID in table orders. You have 2 
options:

   1. delete from orders where Customer_SID=foo
   delete from customer where SID=foo
   2. read 
http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL Foreign Key Issue

2007-03-26 Thread Luchino - Samel

*Question No. 01*
there are some kind of foreign key in database
Some of them want give any error when you delete from the table where the
foreign key is in, this cause the remove is recursive and it delete also
the ORDER linked to the CUSTOMER (CASCADE foreign key).
In other kind of foreign key (I don't remember the name) you cannot delete
CUSTOMER if there is some ORDER linked to them.

hope this will help

c-ya



2007/3/26, Lasitha Alawatta [EMAIL PROTECTED]:


 Hello,



I have 2 issue, regarding MySQL Foreign Key.

I have two tables;

Table 01 *CUSTOMER*

column name

characteristic

SID

Primary Key

Full_Name





Table *ORDERS*

column name

characteristic

Order_ID

Primary Key

Order_Date



Customer_SID

Foreign Key

Amount





When I run ALTER TABLE ORDERS ADD FOREIGN KEY (customer_sid) REFERENCES
CUSTOMER(SID); that sql statement,



I inserted 2 records to both tables.

* *

*Question No. 01.*

Then I removed 1 record from CUSTOMER table. But It want give any error
message. It should give an error message, because in ORDERS table already
have some records relevant to the deleted customer record in CUSTOMER table.



Question is why it want give any error ? (I'm using phpMyAdmin)



*Question No. 02.*

Is there any tool available for to get a Database diagram (like in MS SQL
Server). I found a tool call DBDesigner 4. But it wants show the DB
Diagram.





Thanks in Advance,

Lasitha.







DOTW DISCLAIMER:


This e-mail and any attachments are strictly confidential and intended for the 
addressee only. If you are not the named addressee you must not disclose, copy 
or take

any action in reliance of this transmission and you should notify us as soon as 
possible. If you have received it in error, please contact the message sender 
immediately.

This e-mail and any attachments are believed to be free from viruses but it is 
your responsibility to carry out all necessary virus checks and DOTW accepts no 
liability
in connection therewith.


This e-mail and all other electronic (including voice) communications from the 
sender's company are for informational purposes only.  No such communication is 
intended

by the sender to constitute either an electronic record or an electronic 
signature or to constitute any agreement by the sender to conduct a transaction 
by electronic means.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
Samel alias Luca

Close the world,txen eht nepo!
You will never break my mind!

LinuxUser:410006 eversor:316704 vindicare:316705

Wii owner: 7579-9856-9598-5214


[PHP-DB] MySQL Foreign Key Issue

2007-03-25 Thread Lasitha Alawatta
Hello,

 

I have 2 issue, regarding MySQL Foreign Key.

I have two tables;

Table 01 CUSTOMER 

column name

characteristic

SID

Primary Key

Full_Name

  

 

Table ORDERS 

column name

characteristic

Order_ID

Primary Key

Order_Date

  

Customer_SID

Foreign Key

Amount

  

 

When I run ALTER TABLE ORDERS ADD FOREIGN KEY (customer_sid) REFERENCES
CUSTOMER(SID); that sql statement, 

 

I inserted 2 records to both tables. 

 

Question No. 01.

Then I removed 1 record from CUSTOMER table. But It want give any error
message. It should give an error message, because in ORDERS table
already have some records relevant to the deleted customer record in
CUSTOMER table.

 

Question is why it want give any error ? (I'm using phpMyAdmin)

 

Question No. 02.

Is there any tool available for to get a Database diagram (like in MS
SQL Server). I found a tool call DBDesigner 4. But it wants show the
DB Diagram.

 

 

Thanks in Advance,

Lasitha.

 

 

DOTW DISCLAIMER:

This e-mail and any attachments are strictly confidential and intended for the 
addressee only. If you are not the named addressee you must not disclose, copy 
or take
any action in reliance of this transmission and you should notify us as soon as 
possible. If you have received it in error, please contact the message sender 
immediately.
This e-mail and any attachments are believed to be free from viruses but it is 
your responsibility to carry out all necessary virus checks and DOTW accepts no 
liability
in connection therewith. 

This e-mail and all other electronic (including voice) communications from the 
sender's company are for informational purposes only.  No such communication is 
intended
by the sender to constitute either an electronic record or an electronic 
signature or to constitute any agreement by the sender to conduct a transaction 
by electronic means.
-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php