Re: Leech (?) content of mySQL tables

From: badr (DWEBD_at_msn.com)
Date: 12/20/04


Date: 20 Dec 2004 03:27:10 -0800

hi , knoak

if i undrestand your quz , you are talking about the referential
integrity , that mean you want change , delete or add data to some
filed and it take effect to some other joind table , if so , in MySQL
the foregin key AND referential integrity are not supported in all type
of tables, like MyISAM, or HEAP , but in INNODB type yes they are.
so when you create your won tables you have to implement the
referential integrity by specifying your foreign key and table type.

for example if you have sections and employees and each employee have
difrenet permission to do some job we can make this :
Create table employee ("
emp_id varchar(15) PRIMARY KEY,
login_name varchar(25) not null unique,
login_pass varchar(15) not null,
empname varchar(20) not null,
index (emp_id)") TYPE=INNODB #####check the type (INNODB)

create table permission ("
emp_id Varchar(15) not null,
object_id int not null,
object_name varchar(40) not null,
index (emp_id),
index (object_id),
primary key (emp_id,object_id),
foreign key (emp_id)
references employee (emp_id) on delete cascade on update cascade") ##
here the
TYPE=INNODB #here also the type is INNODB

in this case if you delete employee from employee table its permission
will be deleted also , the same thing for updating. so it will be
cascaded in both operation

chek the versions of MySQL they may make it supported in some versions
http://www.mysql.com/search/?q=referential+integrity+&charset=iso-8859-1

for more information about referential integrity
http://www.databasejournal.com/features/mysql/article.php/2248101



Relevant Pages

  • Re: Implementation of [A]1---->*[B]
    ... So I assume your question is: how does one avoid duplicate references ... if it is considered an error to /try/ to add a participant that is ... of the addresponsibility because it is adding an additional ... A Project holds its own copy of Employee. ...
    (comp.object)
  • Re: OT ~ Happy Days Are Here Again
    ... Every single one of those references go back to the first article in ... White House employee in the meeting told them the President of the ... Not one single source that was actually in the meeting. ... no other source has any references or a name of anyone who was ...
    (rec.outdoors.rv-travel)
  • Re: Wie kann ich Database Integrity =?ISO-8859-1?Q?pr=FCfen=3F?=
    ... user_id INTEGER NOT NULL, ... FOREIGN KEY REFERENCES users); ... Integrity Probleme mit einem Tool rausfinden? ...
    (de.comp.datenbanken.mysql)
  • Re: OT: Job References; are they any real value?
    ... I haven't been an employee (except as a legal fiction for a temp agency, ... I don't like my references to be bothered with a ... give names and numbers of folks I've worked with. ... great programmer... ...
    (comp.lang.cobol)
  • Re: Which database design is better
    ... you can update primary keys because you can ... of employee. ... Remember that part in the specs in this thread about each store ... then I can use a REFERENCES clause. ...
    (microsoft.public.sqlserver.programming)