maes
11-21-2002, 08:17 PM
maybe a dumb question, but how do I make relations with Mysql?
these are my tables:
owner(onwerid, name, ...)
equipment(Serialnr, type...)
between owner and equipment, there is a many to many relation, so I need an other table:
equipment_owner(ownerid, serialnr, date)
how do I make those relations with mysql?
this is how I've done it, is this correct:
$query="create table equipment(
serialnr integer not null auto_increment,
type text,
primary key(serienr))";
$query="create table owner(
ownerid integer not null auto_increment,
name text,
primary key(klantid))";
$query="create table equipment_owner(
serialnr integer not null ,
ownerid integer not null ,
date timestamp(14),
KEY ownerid_serialnr (serialnr,ownerid))";
I'm not sure about the table equipment_owner. How do you make the link with the serialnr of the table equipment and the serialnr of ownerid_serialnr (same with ownerid).
thanks
--maes
these are my tables:
owner(onwerid, name, ...)
equipment(Serialnr, type...)
between owner and equipment, there is a many to many relation, so I need an other table:
equipment_owner(ownerid, serialnr, date)
how do I make those relations with mysql?
this is how I've done it, is this correct:
$query="create table equipment(
serialnr integer not null auto_increment,
type text,
primary key(serienr))";
$query="create table owner(
ownerid integer not null auto_increment,
name text,
primary key(klantid))";
$query="create table equipment_owner(
serialnr integer not null ,
ownerid integer not null ,
date timestamp(14),
KEY ownerid_serialnr (serialnr,ownerid))";
I'm not sure about the table equipment_owner. How do you make the link with the serialnr of the table equipment and the serialnr of ownerid_serialnr (same with ownerid).
thanks
--maes