If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > cascade worked under oracle but mysql?

Closed Thread
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-26-07, 11:50
landonkelsey landonkelsey is offline
Registered User
 
Join Date: Jun 2005
Posts: 21
cascade worked under oracle but mysql?

this should result in empty tables.

Once worked under Oracle but now does not work under MS SQL Server 2005 and mysql

alter table pets_like_boys
drop constraint pets_like;

alter table girls_like_pets
drop constraint girls_like;

alter table boys_like_girls
drop constraint boys_like;

drop table pets_like_boys;
drop table boys_like_girls;
drop table girls_like_pets;

- first time start here

create table pets_like_boys (pets_name varchar(32), boys_name varchar(32),primary key (pets_name));
create table boys_like_girls (boys_name varchar(32), girls_name varchar(32),primary key (boys_name));
create table girls_like_pets (girls_name varchar(32), pets_name varchar(32),primary key (girls_name));

insert into pets_like_boys values('fluffy', 'sam');
insert into pets_like_boys values('rover', 'bob');
insert into pets_like_boys values('skippy', 'joe');

insert into boys_like_girls values('bob','jill');
insert into boys_like_girls values('sam','betty');
insert into boys_like_girls values('joe','sue');
insert into boys_like_girls values('george','jill');

insert into girls_like_pets values('sue','fluffy');
insert into girls_like_pets values('jill','skippy');
insert into girls_like_pets values('betty','rover');

alter table pets_like_boys
add constraint pets_like
foreign key (boys_name )
references boys_like_girls
on delete cascade;

alter table boys_like_girls
add constraint boys_like
foreign key (girls_name )
references girls_like_pets
on delete cascade;

alter table girls_like_pets
add constraint girls_like
foreign key (pets_name )
references pets_like_boys
on delete cascade;


select * from pets_like_boys;
select * from boys_like_girls;
select * from girls_like_pets;
delete from boys_like_girls where boys_name = 'bob';
select * from pets_like_boys;
select * from boys_like_girls;
select * from girls_like_pets;
  #2 (permalink)  
Old 11-26-07, 12:03
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
ur doing it wrong lol

dey gots to be innodb tables, i bets your default is myisam
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
  #3 (permalink)  
Old 11-26-07, 12:19
landonkelsey landonkelsey is offline
Registered User
 
Join Date: Jun 2005
Posts: 21
how does one change that setting

I am just starting to learn mysql
  #4 (permalink)  
Old 11-26-07, 12:26
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
create table pets_like_boys 
( pets_name varchar(32)
, boys_name varchar(32)
, primary key (pets_name)
) engine=innodb;
it's right there in the manual
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
  #5 (permalink)  
Old 11-26-07, 12:29
landonkelsey landonkelsey is offline
Registered User
 
Join Date: Jun 2005
Posts: 21
I would expect cascade to work without any internal option change

since cascade is not a obscure constraint
  #6 (permalink)  
Old 11-26-07, 12:30
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
obviously you are new to mysql
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
  #7 (permalink)  
Old 11-26-07, 12:34
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html
If you omit the ENGINE or TYPE option, the default storage engine is used. Normally, this is MyISAM, but you can change it by using the --default-storage-engine or --default-table-type server startup option, or by setting the default-storage-engine or default-table-type option in the my.cnf configuration file.

You can set the default storage engine to be used during the current session by setting the storage_engine or table_type variable:

SET storage_engine=MYISAM;
SET table_type=BDB;
it's right there in da manual
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
  #8 (permalink)  
Old 11-26-07, 12:44
landonkelsey landonkelsey is offline
Registered User
 
Join Date: Jun 2005
Posts: 21
I'm sure it is in the manual. I should have read all 15,000 pages before trying a select statement. That makes sense doesn't it?

OR

By mental telepathy I should have known about myisam and lookd it up before using a plain old cascade constraint. That makes sense doesn't it?


Again, why such an involved option change for a simple constraint?

This make the SQL non-standard/not portable.

Do you understand? This is a conceptual situation!
  #9 (permalink)  
Old 11-26-07, 12:48
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by landonkelsey
Do you understand? This is a conceptual situation!
i conceptually understand that you are conceptually frustrated and you have my conceptual condolences

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
  #10 (permalink)  
Old 11-26-07, 12:55
landonkelsey landonkelsey is offline
Registered User
 
Join Date: Jun 2005
Posts: 21
curious!!

I am an amateur psych, philos, theolog!

Tell me something!

(1) briefly, what college degrees do you have?

(2) are you a programmer (C#, C++, PHP)?

(3) what are your strengths outside of (I suppose) sql
  #11 (permalink)  
Old 11-26-07, 13:01
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
1) bachelor of science, university of toronto
2) no
3) sweet, sweet lovin

my turn to ask you some questions

1) how old are you
2) what country do you live in
3) please describe the application you are building
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
  #12 (permalink)  
Old 11-26-07, 13:04
landonkelsey landonkelsey is offline
Registered User
 
Join Date: Jun 2005
Posts: 21
sorry!

engine=innodb didn't help

alter table pets_like_boys
drop constraint pets_like;

alter table girls_like_pets
drop constraint girls_like;

alter table boys_like_girls
drop constraint boys_like;

drop table pets_like_boys;
drop table boys_like_girls;
drop table girls_like_pets;

create table pets_like_boys (pets_name varchar(32), boys_name varchar(32),primary key (pets_name))engine=innodb;
create table boys_like_girls (boys_name varchar(32), girls_name varchar(32),primary key (boys_name))engine=innodb;
create table girls_like_pets (girls_name varchar(32), pets_name varchar(32),primary key (girls_name))engine=innodb;

insert into pets_like_boys values('fluffy', 'sam');
insert into pets_like_boys values('rover', 'bob');
insert into pets_like_boys values('skippy', 'joe');

insert into boys_like_girls values('bob','jill');
insert into boys_like_girls values('sam','betty');
insert into boys_like_girls values('joe','sue');
insert into boys_like_girls values('george','jill');

insert into girls_like_pets values('sue','fluffy');
insert into girls_like_pets values('jill','skippy');
insert into girls_like_pets values('betty','rover');

alter table pets_like_boys
add constraint pets_like
foreign key (boys_name )
references boys_like_girls
on delete cascade;

alter table boys_like_girls
add constraint boys_like
foreign key (girls_name )
references girls_like_pets
on delete cascade;

alter table girls_like_pets
add constraint girls_like
foreign key (pets_name )
references pets_like_boys
on delete cascade;


select * from pets_like_boys;
select * from boys_like_girls;
select * from girls_like_pets;
delete from boys_like_girls where boys_name = 'bob';
select * from pets_like_boys;
select * from boys_like_girls;
select * from girls_like_pets;
  #13 (permalink)  
Old 11-26-07, 13:07
landonkelsey landonkelsey is offline
Registered User
 
Join Date: Jun 2005
Posts: 21
1) how old are you 67
2) what country do you live in USA
3) please describe the application you are building |this is an academic exercise

to get to know mysql after Oracle and MS SQL server

BTW I was going to ask! How old are you?
  #14 (permalink)  
Old 11-26-07, 13:09
landonkelsey landonkelsey is offline
Registered User
 
Join Date: Jun 2005
Posts: 21
may I probe further? a question from my academics

(2) What normal form is violated here?
A telephone call is uniquely identified by telephone number and time of call. These candidate keys compose the composite primary key. There is an attribute/column “telephone location”
  #15 (permalink)  
Old 11-26-07, 13:10
landonkelsey landonkelsey is offline
Registered User
 
Join Date: Jun 2005
Posts: 21
no research...just what you know
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
Pingbacks are On
Refbacks are On