Afficher un message
Vieux 23/04/2006, 00h15   #1
bob.herbst@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Newbie question about keys

I am trying to create a simple multitable database. The first table
keeps track of alumni of my association including an id#(key,
auto_increment), firstname, lastname, email and year they graduated.

I am hosting an event so I have an online registration for alumni and I
want them to tell me the name and relationship of upto 4 guests. So i
created a second table called guest with guestid guest lastname,
firstname and relationship as well as a column that has the alumniID of
the alumni they are coming with. I set up this table as follows

CREATE TABLE guest (
gid INT (50) PRIMARY KEY,
glastname CHARACTER (20),
gfirstname CHARACTER (20),
relation CHARACTER (20),
pid BIGINT (100),
CONSTRAINT pidFK FOREIGN KEY (pid)
REFERENCES alumni (pid)
ON DELETE CASCADE
);

I then use PHP and a form to enter data into both the tables. I am
using XAMPP 1.5.1 and when I use phpmyadmin to delete the alumni record
it keeps the guest record and that is not good because then the pid
section references an alumni that is not in the database. I feel like
it doesn't reset the alumniID and therefore it still thinks that a
person with ID still exists, but I could be wrong.

On a related note, what is the best way to make sure the same person
doesn't register more than once. I have it set so that the id number is
the primary key, should I make a field like e-mail unique and not
necesarilly primary?

Thank you for your

  Réponse avec citation
 
Page generated in 0,05105 seconds with 9 queries