Primary / Foreign Key.. how do I?
Posted: Mon Dec 16, 2002 8:00 am
Hello All,
Lets say I want to create a database with 3 tables in it and it looks something like this. The name of the database is memberDirectory
MySQL version:- 3.23.54
OS:- Win 2K Pro
Apache 1.3.xx + PHP 4.2.3
Now my question is, how do I do it such that, the given tables has primary/foreign relationship. Any ideas or help would be appreciated. The actual number of fields is a bit more then what I have here, also I might have a few more tables. I also cannot run MySQL 4.0 or later, since my server is running the above configuration on Linux.
PS:- I also tried to convert the tables to "InnoDB" using the query editor in phpmyadmin and MySQL Control Center and somehow it still registers the tables as MyISAM.
Lets say I want to create a database with 3 tables in it and it looks something like this. The name of the database is memberDirectory
MySQL version:- 3.23.54
OS:- Win 2K Pro
Apache 1.3.xx + PHP 4.2.3
Code: Select all
CREATE TABLE tblPrimary
(
emailAddress varchar(100) NOT NULL default '',
password varchar(16) default NULL,
password2 varchar(16) default NULL,
UNIQUE KEY emailAddress (emailAddress)
) TYPE=MyISAM;
CREATE TABLE tblMember
(
memberID mediumint(9) NOT NULL auto_increment,
emailAddress varchar(100) default NULL, <--- I want this to be a foreign key to this table
lastName varchar(50) default NULL,
firstName varchar(50) default NULL,
PRIMARY KEY (memberID)
) TYPE=MyISAM;
CREATE TABLE tblFamily
(
familyID mediumint(9) NOT NULL auto_increment,
memberID mediumint(9) default NULL, <--- I want this to be a foreign key to this table
emailAddress varchar(100) default NULL, <--- I want this to be a foreign key to this table
firstName varchar(50) default NULL,
maritalStatus varchar(15) default NULL,
Occupation varchar(25) default NULL,
) TYPE=MyISAM;PS:- I also tried to convert the tables to "InnoDB" using the query editor in phpmyadmin and MySQL Control Center and somehow it still registers the tables as MyISAM.