CREATE TABLE isikud(
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  eesnimi VARCHAR(50) NOT NULL,
  synniaasta INT NOT NULL,
  isa_id INT,
  ema_id INT
);

Lapsed:
       Juku 2005              Kati 2003
Vanemad:             
       Martin 1970  	      Anne 1974
Vanavanemad
    Juhan 1935	Marta 1938

INSERT INTO isikud(eesnimi, synniaasta) VALUES('Juhan', 1935);
INSERT INTO isikud(eesnimi, synniaasta) VALUES('Marta', 1938);


mysql> SELECT * FROM isikud;
+----+---------+------------+--------+--------+
| id | eesnimi | synniaasta | isa_id | ema_id |
+----+---------+------------+--------+--------+
|  1 | Juhan   |       1935 |   NULL |   NULL |
|  2 | Marta   |       1938 |   NULL |   NULL |
+----+---------+------------+--------+--------+

INSERT INTO isikud(eesnimi, synniaasta, isa_id, ema_id)
 VALUES ('Martin', 1970, 1, 2);


INSERT INTO isikud(eesnimi, synniaasta) VALUES ('Anne', 1974);


mysql> SELECT * FROM isikud;                                          +----+---------+------------+--------+--------+
| id | eesnimi | synniaasta | isa_id | ema_id |
+----+---------+------------+--------+--------+
|  1 | Juhan   |       1935 |   NULL |   NULL |
|  2 | Marta   |       1938 |   NULL |   NULL |
|  3 | Martin  |       1970 |      1 |      2 |
|  4 | Anne    |       1974 |   NULL |   NULL |
+----+---------+------------+--------+--------+


INSERT INTO isikud(eesnimi, synniaasta, isa_id, ema_id)
 VALUES ('Juku', 2005, 3, 4);

INSERT INTO isikud(eesnimi, synniaasta, isa_id, ema_id)
 VALUES ('Kati', 2003, 3, 4);


mysql> SELECT * FROM isikud;
+----+---------+------------+--------+--------+
| id | eesnimi | synniaasta | isa_id | ema_id |
+----+---------+------------+--------+--------+
|  1 | Juhan   |       1935 |   NULL |   NULL |
|  2 | Marta   |       1938 |   NULL |   NULL |
|  3 | Martin  |       1970 |      1 |      2 |
|  4 | Anne    |       1974 |   NULL |   NULL |
|  5 | Juku    |       2005 |      3 |      4 |
|  6 | Kati    |       2003 |      3 |      4 |
+----+---------+------------+--------+--------+

SELECT eesnimi FROM isikud;

SELECT *
  FROM isikud uuritavad, isikud as isad
   WHERE uuritavad.isa_id=isad.id;