title: How to add a foreign key constraint which refers to a primary key of the same table ( self reference)
body: <p>Hello Everyone, 
                     I would like to create a table which has primary key and a foreign key. The foreign key however references the primary key of the same table. I have read online and found out that in order to add this kind of constraint, I first need to drop this constraint, load the data and then user ALTER command to add the constraint. However, this does not seem to to work. 
  Here's the query: </p>
  
  <pre><code>DROP TABLE employee;
  CREATE TABLE employee (
    fname    varchar(15) not null, 
    minit    varchar(1),
    lname    varchar(15) not null,
    ssn      char(9),
    bdate    date,
    address  varchar(50),
    sex      char,
    salary   decimal(10,2),
    superssn char(9),
    dno      integer(4),
    primary key (ssn),
    foreign key (superssn) references employee(ssn),
    foreign key (dno) references department(dnumber)
  );
  </code></pre>
  
  <p>and this is how I load the data in the table. </p>
  
  <pre><code>LOAD DATA LOCAL INFILE "employee.dat" 
  INTO TABLE employee 
  FIELDS ENCLOSED BY "\"" TERMINATED BY ","
  ;
  </code></pre>
  
  <p>I would very much appreciate if you can give me a hint on how to accomplish this. </p>