Hi,im trying to insert into table student_acedamic_history but I get this error.Heres my code.
CREATE TABLE Student_Acedamic_History(

    S_id INT,


Degree_Title VARCHAR(30),
Institue VARCHAR(30),
Year_Of_Comp INT,
Total_Marks INT,
Obtained_Marks INT,
PercentAge FLOAT,
CONSTRAINT fk_S_id_students FOREIGN KEY student_acedamic_history(S_id)REFERENCES students (S_id)ON UPDATE CASCADE ON DELETE CASCADE

);
And the data:
INSERT INTO student_acedamic_history VALUES
(1,'FSC','GBHS',2013,1100,900,81.81),(2,'FA','PAF',2012,1100,850,77.28),(3,'ICS','APS',2011,1100,800,73),(4,'I_COM','GC',2010,1100,750,68.18),(5,'MATRIC','FC',2009,1050,800,76.2),
(6,'FSC','GBHS',2013,1100,900,81.81),(7,'FA','PAF',2012,1100,850,77.28),(8,'ICS','APS',2011,1100,800,73),(9,'I_COM','GC',2010,1100,750,68.18),(10,'MATRIC','FC',2009,1050,800,76.2),
(11,'FSC','GBHS',2013,1100,900,81.81),(12,'FA','PAF',2012,1100,850,77.28),(13,'ICS','APS',2011,1100,800,73),(14,'I_COM','GC',2010,1100,750,68.18),(15,'MATRIC','FC',2009,1050,800,76.2),
(16,'FSC','GBHS',2013,1100,900,81.81),(17,'FA','PAF',2012,1100,850,77.28),(18,'ICS','APS',2011,1100,800,73),(19,'I_COM','GC',2010,1100,750,68.18),(20,'MATRIC','FC',2009,1050,800,76.2),
(21,'FSC','GBHS',2013,1100,900,81.81),(22,'FA','PAF',2012,1100,850,77.28),(23,'ICS','APS',2011,1100,800,73),(24,'I_COM','GC',2010,1100,750,68.18),(25,'MATRIC','FC',2009,1050,800,76.2),
(26,'FSC','GBHS',2013,1100,900,81.81),(27,'FA','PAF',2012,1100,850,77.28),(28,'ICS','APS',2011,1100,800,73),(29,'I_COM','GC',2010,1100,750,68.18),(30,'MATRIC','FC',2009,1050,800,76.2),
(31,'FSC','GBHS',2013,1100,900,81.81),(32,'FA','PAF',2012,1100,850,77.28),(33,'ICS','APS',2011,1100,800,73),(34,'I_COM','GC',2010,1100,750,68.18),(35,'MATRIC','FC',2009,1050,800,76.2),
(36,'FSC','GBHS',2013,1100,900,81.81),(37,'FA','PAF',2012,1100,850,77.28),(38,'ICS','APS',2011,1100,800,73),(39,'I_COM','GC',2010,1100,750,68.18),(40,'MATRIC','FC',2009,1050,800,76.2),
(41,'FSC','GBHS',2013,1100,900,81.81),(42,'FA','PAF',2012,1100,850,77.28),(43,'ICS','APS',2011,1100,800,73),(44,'I_COM','GC',2010,1100,750,68.18),(45,'MATRIC','FC',2009,1050,800,76.2),
(46,'FSC','GBHS',2013,1100,900,81.81),(47,'FA','PAF',2012,1100,850,77.28),(48,'ICS','APS',2011,1100,800,73),(49,'I_COM','GC',2010,1100,750,68.18),(50,'MATRIC','FC',2009,1050,800,76.2);

Foreign key constraints prevent INSERT and UPDATE commands if the corrosponding key is found in the referenced table.
That means the s_id value you are trying to insert into student_academic_history must already exist in students.
This is half the reason you put in a foreign key constraint anyway.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.