From bfed705122ab5e29bcb832f15e6ec43134865757 Mon Sep 17 00:00:00 2001 From: Jiaxiang Yu Date: Thu, 24 Mar 2022 19:12:30 +0800 Subject: [PATCH 1/7] add initial fake data, to be cleaned --- fake_data/50/COURSE.sql | 51 ++++++++++++++++++++ fake_data/50/ENROLL.sql | 51 ++++++++++++++++++++ fake_data/50/SECTION.sql | 51 ++++++++++++++++++++ fake_data/50/STAFF.sql | 51 ++++++++++++++++++++ fake_data/50/STUDENT.sql | 51 ++++++++++++++++++++ fake_data/backup/50/COURSE.sql | 54 ++++++++++++++++++++++ fake_data/backup/50/ENROLL.sql | 54 ++++++++++++++++++++++ fake_data/backup/50/SECTION.sql | 54 ++++++++++++++++++++++ fake_data/backup/50/STAFF.sql | 54 ++++++++++++++++++++++ fake_data/backup/50/STUDENT.sql | 54 ++++++++++++++++++++++ fake_data/parse.py | 82 +++++++++++++++++++++++++++++++++ 11 files changed, 607 insertions(+) create mode 100644 fake_data/50/COURSE.sql create mode 100644 fake_data/50/ENROLL.sql create mode 100644 fake_data/50/SECTION.sql create mode 100644 fake_data/50/STAFF.sql create mode 100644 fake_data/50/STUDENT.sql create mode 100644 fake_data/backup/50/COURSE.sql create mode 100644 fake_data/backup/50/ENROLL.sql create mode 100644 fake_data/backup/50/SECTION.sql create mode 100644 fake_data/backup/50/STAFF.sql create mode 100644 fake_data/backup/50/STUDENT.sql create mode 100644 fake_data/parse.py diff --git a/fake_data/50/COURSE.sql b/fake_data/50/COURSE.sql new file mode 100644 index 0000000..edccbaf --- /dev/null +++ b/fake_data/50/COURSE.sql @@ -0,0 +1,51 @@ +CREATE TABLE COURSE (cid int, cname varchar(50)) +INSERT INTO COURSE (cid, cname) VALUES(1,'Dramatics') +INSERT INTO COURSE (cid, cname) VALUES(2,'Grammar') +INSERT INTO COURSE (cid, cname) VALUES(3,'American Literature') +INSERT INTO COURSE (cid, cname) VALUES(4,'Mathematics') +INSERT INTO COURSE (cid, cname) VALUES(5,'Sociology') +INSERT INTO COURSE (cid, cname) VALUES(6,'Basic Math') +INSERT INTO COURSE (cid, cname) VALUES(7,'History') +INSERT INTO COURSE (cid, cname) VALUES(8,'Music') +INSERT INTO COURSE (cid, cname) VALUES(9,'Mathematics') +INSERT INTO COURSE (cid, cname) VALUES(10,'Speech') +INSERT INTO COURSE (cid, cname) VALUES(11,'Speech') +INSERT INTO COURSE (cid, cname) VALUES(12,'Latin') +INSERT INTO COURSE (cid, cname) VALUES(13,'Speech') +INSERT INTO COURSE (cid, cname) VALUES(14,'Physical Education') +INSERT INTO COURSE (cid, cname) VALUES(15,'American Literature') +INSERT INTO COURSE (cid, cname) VALUES(16,'Latin') +INSERT INTO COURSE (cid, cname) VALUES(17,'Basic Math') +INSERT INTO COURSE (cid, cname) VALUES(18,'Economics') +INSERT INTO COURSE (cid, cname) VALUES(19,'American Literature') +INSERT INTO COURSE (cid, cname) VALUES(20,'Basic Math') +INSERT INTO COURSE (cid, cname) VALUES(21,'Sociology') +INSERT INTO COURSE (cid, cname) VALUES(22,'History') +INSERT INTO COURSE (cid, cname) VALUES(23,'Speech') +INSERT INTO COURSE (cid, cname) VALUES(24,'Earth Science') +INSERT INTO COURSE (cid, cname) VALUES(25,'Economics') +INSERT INTO COURSE (cid, cname) VALUES(26,'Speech') +INSERT INTO COURSE (cid, cname) VALUES(27,'Geography') +INSERT INTO COURSE (cid, cname) VALUES(28,'Dramatics') +INSERT INTO COURSE (cid, cname) VALUES(29,'Trigonometry') +INSERT INTO COURSE (cid, cname) VALUES(30,'Dramatics') +INSERT INTO COURSE (cid, cname) VALUES(31,'Language Arts') +INSERT INTO COURSE (cid, cname) VALUES(32,'Geography') +INSERT INTO COURSE (cid, cname) VALUES(33,'Mathematics') +INSERT INTO COURSE (cid, cname) VALUES(34,'Basic Math') +INSERT INTO COURSE (cid, cname) VALUES(35,'Dramatics') +INSERT INTO COURSE (cid, cname) VALUES(36,'Trigonometry') +INSERT INTO COURSE (cid, cname) VALUES(37,'Grammar') +INSERT INTO COURSE (cid, cname) VALUES(38,'American Literature') +INSERT INTO COURSE (cid, cname) VALUES(39,'Dramatics') +INSERT INTO COURSE (cid, cname) VALUES(40,'Speech') +INSERT INTO COURSE (cid, cname) VALUES(41,'History') +INSERT INTO COURSE (cid, cname) VALUES(42,'Ecology') +INSERT INTO COURSE (cid, cname) VALUES(43,'Health') +INSERT INTO COURSE (cid, cname) VALUES(44,'Dramatics') +INSERT INTO COURSE (cid, cname) VALUES(45,'Earth Science') +INSERT INTO COURSE (cid, cname) VALUES(46,'Ecology') +INSERT INTO COURSE (cid, cname) VALUES(47,'Sociology') +INSERT INTO COURSE (cid, cname) VALUES(48,'Sociology') +INSERT INTO COURSE (cid, cname) VALUES(49,'Physical Education') +INSERT INTO COURSE (cid, cname) VALUES(50,'History') \ No newline at end of file diff --git a/fake_data/50/ENROLL.sql b/fake_data/50/ENROLL.sql new file mode 100644 index 0000000..8673d7f --- /dev/null +++ b/fake_data/50/ENROLL.sql @@ -0,0 +1,51 @@ +CREATE TABLE ENROLL (eid int, studentid int, sectionid int) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(1,4,28) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(2,2,42) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(3,24,39) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(4,35,4) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(5,5,38) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(6,45,23) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(7,22,23) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(8,37,22) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(9,2,17) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(10,19,35) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(11,47,41) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(12,9,27) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(13,23,33) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(14,32,36) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(15,45,32) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(16,5,9) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(17,37,12) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(18,2,37) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(19,42,46) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(20,35,23) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(21,40,2) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(22,47,43) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(23,28,27) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(24,20,17) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(25,23,49) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(26,36,26) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(27,28,22) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(28,15,12) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(29,20,24) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(30,20,40) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(31,7,49) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(32,9,23) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(33,33,36) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(34,35,11) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(35,22,49) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(36,29,5) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(37,32,45) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(38,45,45) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(39,44,15) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(40,49,45) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(41,14,16) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(42,13,46) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(43,45,28) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(44,31,16) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(45,47,39) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(46,18,19) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(47,27,45) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(48,16,40) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(49,43,24) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(50,11,41) \ No newline at end of file diff --git a/fake_data/50/SECTION.sql b/fake_data/50/SECTION.sql new file mode 100644 index 0000000..baf2b44 --- /dev/null +++ b/fake_data/50/SECTION.sql @@ -0,0 +1,51 @@ +CREATE TABLE SECTION (secid int, courseid int, staffid int) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(1,27,25) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(2,14,40) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(3,37,48) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(4,6,13) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(5,7,24) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(6,39,32) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(7,13,13) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(8,28,22) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(9,11,16) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(10,5,6) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(11,36,16) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(12,31,20) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(13,10,8) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(14,36,8) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(15,45,5) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(16,42,6) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(17,25,24) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(18,41,39) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(19,31,13) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(20,5,7) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(21,47,5) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(22,7,3) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(23,14,29) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(24,37,11) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(25,1,8) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(26,15,31) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(27,4,45) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(28,49,12) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(29,43,43) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(30,31,30) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(31,13,47) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(32,17,3) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(33,32,33) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(34,8,39) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(35,21,38) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(36,41,47) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(37,11,48) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(38,8,31) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(39,9,29) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(40,7,30) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(41,20,25) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(42,7,38) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(43,39,12) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(44,3,29) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(45,24,29) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(46,45,37) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(47,32,25) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(48,44,49) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(49,38,5) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(50,21,31) \ No newline at end of file diff --git a/fake_data/50/STAFF.sql b/fake_data/50/STAFF.sql new file mode 100644 index 0000000..33a9df6 --- /dev/null +++ b/fake_data/50/STAFF.sql @@ -0,0 +1,51 @@ +CREATE TABLE STAFF (stid int, stname varchar(50)) +INSERT INTO STAFF (stid, stname) VALUES(1,'Henry') +INSERT INTO STAFF (stid, stname) VALUES(2,'Katelyn') +INSERT INTO STAFF (stid, stname) VALUES(3,'Olivia') +INSERT INTO STAFF (stid, stname) VALUES(4,'Chris') +INSERT INTO STAFF (stid, stname) VALUES(5,'Chris') +INSERT INTO STAFF (stid, stname) VALUES(6,'Rufus') +INSERT INTO STAFF (stid, stname) VALUES(7,'Ramon') +INSERT INTO STAFF (stid, stname) VALUES(8,'Jolene') +INSERT INTO STAFF (stid, stname) VALUES(9,'Denny') +INSERT INTO STAFF (stid, stname) VALUES(10,'William') +INSERT INTO STAFF (stid, stname) VALUES(11,'Callie') +INSERT INTO STAFF (stid, stname) VALUES(12,'Danny') +INSERT INTO STAFF (stid, stname) VALUES(13,'Susan') +INSERT INTO STAFF (stid, stname) VALUES(14,'Nick') +INSERT INTO STAFF (stid, stname) VALUES(15,'Liam') +INSERT INTO STAFF (stid, stname) VALUES(16,'Caleb') +INSERT INTO STAFF (stid, stname) VALUES(17,'Sebastian') +INSERT INTO STAFF (stid, stname) VALUES(18,'Clint') +INSERT INTO STAFF (stid, stname) VALUES(19,'Percy') +INSERT INTO STAFF (stid, stname) VALUES(20,'Parker') +INSERT INTO STAFF (stid, stname) VALUES(21,'Julian') +INSERT INTO STAFF (stid, stname) VALUES(22,'Grace') +INSERT INTO STAFF (stid, stname) VALUES(23,'Cassandra') +INSERT INTO STAFF (stid, stname) VALUES(24,'Denis') +INSERT INTO STAFF (stid, stname) VALUES(25,'Abdul') +INSERT INTO STAFF (stid, stname) VALUES(26,'Liam') +INSERT INTO STAFF (stid, stname) VALUES(27,'Cassidy') +INSERT INTO STAFF (stid, stname) VALUES(28,'Adeline') +INSERT INTO STAFF (stid, stname) VALUES(29,'Tiffany') +INSERT INTO STAFF (stid, stname) VALUES(30,'Kieth') +INSERT INTO STAFF (stid, stname) VALUES(31,'Elijah') +INSERT INTO STAFF (stid, stname) VALUES(32,'Keira') +INSERT INTO STAFF (stid, stname) VALUES(33,'Russel') +INSERT INTO STAFF (stid, stname) VALUES(34,'Chuck') +INSERT INTO STAFF (stid, stname) VALUES(35,'Fred') +INSERT INTO STAFF (stid, stname) VALUES(36,'Olivia') +INSERT INTO STAFF (stid, stname) VALUES(37,'Catherine') +INSERT INTO STAFF (stid, stname) VALUES(38,'Alex') +INSERT INTO STAFF (stid, stname) VALUES(39,'Denny') +INSERT INTO STAFF (stid, stname) VALUES(40,'Johnathan') +INSERT INTO STAFF (stid, stname) VALUES(41,'Zoe') +INSERT INTO STAFF (stid, stname) VALUES(42,'Roger') +INSERT INTO STAFF (stid, stname) VALUES(43,'Ramon') +INSERT INTO STAFF (stid, stname) VALUES(44,'Allison') +INSERT INTO STAFF (stid, stname) VALUES(45,'Ruby') +INSERT INTO STAFF (stid, stname) VALUES(46,'Johnny') +INSERT INTO STAFF (stid, stname) VALUES(47,'Iris') +INSERT INTO STAFF (stid, stname) VALUES(48,'Analise') +INSERT INTO STAFF (stid, stname) VALUES(49,'Nick') +INSERT INTO STAFF (stid, stname) VALUES(50,'Aileen') \ No newline at end of file diff --git a/fake_data/50/STUDENT.sql b/fake_data/50/STUDENT.sql new file mode 100644 index 0000000..87dee27 --- /dev/null +++ b/fake_data/50/STUDENT.sql @@ -0,0 +1,51 @@ +CREATE TABLE STUDENT (sid int, sname varchar(50)) +INSERT INTO STUDENT (sid, sname) VALUES(1,'Adalie') +INSERT INTO STUDENT (sid, sname) VALUES(2,'Tyson') +INSERT INTO STUDENT (sid, sname) VALUES(3,'Domenic') +INSERT INTO STUDENT (sid, sname) VALUES(4,'Karla') +INSERT INTO STUDENT (sid, sname) VALUES(5,'Luke') +INSERT INTO STUDENT (sid, sname) VALUES(6,'Darlene') +INSERT INTO STUDENT (sid, sname) VALUES(7,'Caleb') +INSERT INTO STUDENT (sid, sname) VALUES(8,'Denny') +INSERT INTO STUDENT (sid, sname) VALUES(9,'Mya') +INSERT INTO STUDENT (sid, sname) VALUES(10,'Melania') +INSERT INTO STUDENT (sid, sname) VALUES(11,'Roger') +INSERT INTO STUDENT (sid, sname) VALUES(12,'Melody') +INSERT INTO STUDENT (sid, sname) VALUES(13,'Tony') +INSERT INTO STUDENT (sid, sname) VALUES(14,'Luna') +INSERT INTO STUDENT (sid, sname) VALUES(15,'Alexander') +INSERT INTO STUDENT (sid, sname) VALUES(16,'Samara') +INSERT INTO STUDENT (sid, sname) VALUES(17,'Tyler') +INSERT INTO STUDENT (sid, sname) VALUES(18,'Chuck') +INSERT INTO STUDENT (sid, sname) VALUES(19,'Carmella') +INSERT INTO STUDENT (sid, sname) VALUES(20,'Nick') +INSERT INTO STUDENT (sid, sname) VALUES(21,'Sylvia') +INSERT INTO STUDENT (sid, sname) VALUES(22,'Harvey') +INSERT INTO STUDENT (sid, sname) VALUES(23,'Matt') +INSERT INTO STUDENT (sid, sname) VALUES(24,'Mason') +INSERT INTO STUDENT (sid, sname) VALUES(25,'Mya') +INSERT INTO STUDENT (sid, sname) VALUES(26,'Johnathan') +INSERT INTO STUDENT (sid, sname) VALUES(27,'Morgan') +INSERT INTO STUDENT (sid, sname) VALUES(28,'Esmeralda') +INSERT INTO STUDENT (sid, sname) VALUES(29,'Russel') +INSERT INTO STUDENT (sid, sname) VALUES(30,'Gil') +INSERT INTO STUDENT (sid, sname) VALUES(31,'Anthony') +INSERT INTO STUDENT (sid, sname) VALUES(32,'Manuel') +INSERT INTO STUDENT (sid, sname) VALUES(33,'Sonya') +INSERT INTO STUDENT (sid, sname) VALUES(34,'Mary') +INSERT INTO STUDENT (sid, sname) VALUES(35,'Luke') +INSERT INTO STUDENT (sid, sname) VALUES(36,'Manuel') +INSERT INTO STUDENT (sid, sname) VALUES(37,'Iris') +INSERT INTO STUDENT (sid, sname) VALUES(38,'Callie') +INSERT INTO STUDENT (sid, sname) VALUES(39,'Ema') +INSERT INTO STUDENT (sid, sname) VALUES(40,'Ron') +INSERT INTO STUDENT (sid, sname) VALUES(41,'Bethany') +INSERT INTO STUDENT (sid, sname) VALUES(42,'Nick') +INSERT INTO STUDENT (sid, sname) VALUES(43,'Danny') +INSERT INTO STUDENT (sid, sname) VALUES(44,'Oliver') +INSERT INTO STUDENT (sid, sname) VALUES(45,'Anais') +INSERT INTO STUDENT (sid, sname) VALUES(46,'Maxwell') +INSERT INTO STUDENT (sid, sname) VALUES(47,'Ronald') +INSERT INTO STUDENT (sid, sname) VALUES(48,'Karla') +INSERT INTO STUDENT (sid, sname) VALUES(49,'Celia') +INSERT INTO STUDENT (sid, sname) VALUES(50,'Mona') \ No newline at end of file diff --git a/fake_data/backup/50/COURSE.sql b/fake_data/backup/50/COURSE.sql new file mode 100644 index 0000000..19e70c1 --- /dev/null +++ b/fake_data/backup/50/COURSE.sql @@ -0,0 +1,54 @@ +/*script generated for free with OnlineDataGenerator available at: https://www.onlinedatagenerator.com */ +CREATE TABLE MOCKDATA(cid BIGINT,cname VARCHAR(500)); + +INSERT INTO MOCKDATA VALUES('1','Dramatics'); +INSERT INTO MOCKDATA VALUES('2','Grammar'); +INSERT INTO MOCKDATA VALUES('3','American Literature'); +INSERT INTO MOCKDATA VALUES('4','Mathematics'); +INSERT INTO MOCKDATA VALUES('5','Sociology'); +INSERT INTO MOCKDATA VALUES('6','Basic Math'); +INSERT INTO MOCKDATA VALUES('7','History'); +INSERT INTO MOCKDATA VALUES('8','Music'); +INSERT INTO MOCKDATA VALUES('9','Mathematics'); +INSERT INTO MOCKDATA VALUES('10','Speech'); +INSERT INTO MOCKDATA VALUES('11','Speech'); +INSERT INTO MOCKDATA VALUES('12','Latin'); +INSERT INTO MOCKDATA VALUES('13','Speech'); +INSERT INTO MOCKDATA VALUES('14','Physical Education'); +INSERT INTO MOCKDATA VALUES('15','American Literature'); +INSERT INTO MOCKDATA VALUES('16','Latin'); +INSERT INTO MOCKDATA VALUES('17','Basic Math'); +INSERT INTO MOCKDATA VALUES('18','Economics'); +INSERT INTO MOCKDATA VALUES('19','American Literature'); +INSERT INTO MOCKDATA VALUES('20','Basic Math'); +INSERT INTO MOCKDATA VALUES('21','Sociology'); +INSERT INTO MOCKDATA VALUES('22','History'); +INSERT INTO MOCKDATA VALUES('23','Speech'); +INSERT INTO MOCKDATA VALUES('24','Earth Science'); +INSERT INTO MOCKDATA VALUES('25','Economics'); +INSERT INTO MOCKDATA VALUES('26','Speech'); +INSERT INTO MOCKDATA VALUES('27','Geography'); +INSERT INTO MOCKDATA VALUES('28','Dramatics'); +INSERT INTO MOCKDATA VALUES('29','Trigonometry'); +INSERT INTO MOCKDATA VALUES('30','Dramatics'); +INSERT INTO MOCKDATA VALUES('31','Language Arts'); +INSERT INTO MOCKDATA VALUES('32','Geography'); +INSERT INTO MOCKDATA VALUES('33','Mathematics'); +INSERT INTO MOCKDATA VALUES('34','Basic Math'); +INSERT INTO MOCKDATA VALUES('35','Dramatics'); +INSERT INTO MOCKDATA VALUES('36','Trigonometry'); +INSERT INTO MOCKDATA VALUES('37','Grammar'); +INSERT INTO MOCKDATA VALUES('38','American Literature'); +INSERT INTO MOCKDATA VALUES('39','Dramatics'); +INSERT INTO MOCKDATA VALUES('40','Speech'); +INSERT INTO MOCKDATA VALUES('41','History'); +INSERT INTO MOCKDATA VALUES('42','Ecology'); +INSERT INTO MOCKDATA VALUES('43','Health'); +INSERT INTO MOCKDATA VALUES('44','Dramatics'); +INSERT INTO MOCKDATA VALUES('45','Earth Science'); +INSERT INTO MOCKDATA VALUES('46','Ecology'); +INSERT INTO MOCKDATA VALUES('47','Sociology'); +INSERT INTO MOCKDATA VALUES('48','Sociology'); +INSERT INTO MOCKDATA VALUES('49','Physical Education'); +INSERT INTO MOCKDATA VALUES('50','History'); + diff --git a/fake_data/backup/50/ENROLL.sql b/fake_data/backup/50/ENROLL.sql new file mode 100644 index 0000000..3f16616 --- /dev/null +++ b/fake_data/backup/50/ENROLL.sql @@ -0,0 +1,54 @@ +/*script generated for free with OnlineDataGenerator available at: https://www.onlinedatagenerator.com */ +CREATE TABLE MOCKDATA(eid BIGINT,studentid INT,sectionid INT); + +INSERT INTO MOCKDATA VALUES('1',4,28); +INSERT INTO MOCKDATA VALUES('2',2,42); +INSERT INTO MOCKDATA VALUES('3',24,39); +INSERT INTO MOCKDATA VALUES('4',35,4); +INSERT INTO MOCKDATA VALUES('5',5,38); +INSERT INTO MOCKDATA VALUES('6',45,23); +INSERT INTO MOCKDATA VALUES('7',22,23); +INSERT INTO MOCKDATA VALUES('8',37,22); +INSERT INTO MOCKDATA VALUES('9',2,17); +INSERT INTO MOCKDATA VALUES('10',19,35); +INSERT INTO MOCKDATA VALUES('11',47,41); +INSERT INTO MOCKDATA VALUES('12',9,27); +INSERT INTO MOCKDATA VALUES('13',23,33); +INSERT INTO MOCKDATA VALUES('14',32,36); +INSERT INTO MOCKDATA VALUES('15',45,32); +INSERT INTO MOCKDATA VALUES('16',5,9); +INSERT INTO MOCKDATA VALUES('17',37,12); +INSERT INTO MOCKDATA VALUES('18',2,37); +INSERT INTO MOCKDATA VALUES('19',42,46); +INSERT INTO MOCKDATA VALUES('20',35,23); +INSERT INTO MOCKDATA VALUES('21',40,2); +INSERT INTO MOCKDATA VALUES('22',47,43); +INSERT INTO MOCKDATA VALUES('23',28,27); +INSERT INTO MOCKDATA VALUES('24',20,17); +INSERT INTO MOCKDATA VALUES('25',23,49); +INSERT INTO MOCKDATA VALUES('26',36,26); +INSERT INTO MOCKDATA VALUES('27',28,22); +INSERT INTO MOCKDATA VALUES('28',15,12); +INSERT INTO MOCKDATA VALUES('29',20,24); +INSERT INTO MOCKDATA VALUES('30',20,40); +INSERT INTO MOCKDATA VALUES('31',7,49); +INSERT INTO MOCKDATA VALUES('32',9,23); +INSERT INTO MOCKDATA VALUES('33',33,36); +INSERT INTO MOCKDATA VALUES('34',35,11); +INSERT INTO MOCKDATA VALUES('35',22,49); +INSERT INTO MOCKDATA VALUES('36',29,5); +INSERT INTO MOCKDATA VALUES('37',32,45); +INSERT INTO MOCKDATA VALUES('38',45,45); +INSERT INTO MOCKDATA VALUES('39',44,15); +INSERT INTO MOCKDATA VALUES('40',49,45); +INSERT INTO MOCKDATA VALUES('41',14,16); +INSERT INTO MOCKDATA VALUES('42',13,46); +INSERT INTO MOCKDATA VALUES('43',45,28); +INSERT INTO MOCKDATA VALUES('44',31,16); +INSERT INTO MOCKDATA VALUES('45',47,39); +INSERT INTO MOCKDATA VALUES('46',18,19); +INSERT INTO MOCKDATA VALUES('47',27,45); +INSERT INTO MOCKDATA VALUES('48',16,40); +INSERT INTO MOCKDATA VALUES('49',43,24); +INSERT INTO MOCKDATA VALUES('50',11,41); + diff --git a/fake_data/backup/50/SECTION.sql b/fake_data/backup/50/SECTION.sql new file mode 100644 index 0000000..77e5774 --- /dev/null +++ b/fake_data/backup/50/SECTION.sql @@ -0,0 +1,54 @@ +/*script generated for free with OnlineDataGenerator available at: https://www.onlinedatagenerator.com */ +CREATE TABLE MOCKDATA(secid BIGINT,courseid INT,staffid INT); + +INSERT INTO MOCKDATA VALUES('1',27,25); +INSERT INTO MOCKDATA VALUES('2',14,40); +INSERT INTO MOCKDATA VALUES('3',37,48); +INSERT INTO MOCKDATA VALUES('4',6,13); +INSERT INTO MOCKDATA VALUES('5',7,24); +INSERT INTO MOCKDATA VALUES('6',39,32); +INSERT INTO MOCKDATA VALUES('7',13,13); +INSERT INTO MOCKDATA VALUES('8',28,22); +INSERT INTO MOCKDATA VALUES('9',11,16); +INSERT INTO MOCKDATA VALUES('10',5,6); +INSERT INTO MOCKDATA VALUES('11',36,16); +INSERT INTO MOCKDATA VALUES('12',31,20); +INSERT INTO MOCKDATA VALUES('13',10,8); +INSERT INTO MOCKDATA VALUES('14',36,8); +INSERT INTO MOCKDATA VALUES('15',45,5); +INSERT INTO MOCKDATA VALUES('16',42,6); +INSERT INTO MOCKDATA VALUES('17',25,24); +INSERT INTO MOCKDATA VALUES('18',41,39); +INSERT INTO MOCKDATA VALUES('19',31,13); +INSERT INTO MOCKDATA VALUES('20',5,7); +INSERT INTO MOCKDATA VALUES('21',47,5); +INSERT INTO MOCKDATA VALUES('22',7,3); +INSERT INTO MOCKDATA VALUES('23',14,29); +INSERT INTO MOCKDATA VALUES('24',37,11); +INSERT INTO MOCKDATA VALUES('25',1,8); +INSERT INTO MOCKDATA VALUES('26',15,31); +INSERT INTO MOCKDATA VALUES('27',4,45); +INSERT INTO MOCKDATA VALUES('28',49,12); +INSERT INTO MOCKDATA VALUES('29',43,43); +INSERT INTO MOCKDATA VALUES('30',31,30); +INSERT INTO MOCKDATA VALUES('31',13,47); +INSERT INTO MOCKDATA VALUES('32',17,3); +INSERT INTO MOCKDATA VALUES('33',32,33); +INSERT INTO MOCKDATA VALUES('34',8,39); +INSERT INTO MOCKDATA VALUES('35',21,38); +INSERT INTO MOCKDATA VALUES('36',41,47); +INSERT INTO MOCKDATA VALUES('37',11,48); +INSERT INTO MOCKDATA VALUES('38',8,31); +INSERT INTO MOCKDATA VALUES('39',9,29); +INSERT INTO MOCKDATA VALUES('40',7,30); +INSERT INTO MOCKDATA VALUES('41',20,25); +INSERT INTO MOCKDATA VALUES('42',7,38); +INSERT INTO MOCKDATA VALUES('43',39,12); +INSERT INTO MOCKDATA VALUES('44',3,29); +INSERT INTO MOCKDATA VALUES('45',24,29); +INSERT INTO MOCKDATA VALUES('46',45,37); +INSERT INTO MOCKDATA VALUES('47',32,25); +INSERT INTO MOCKDATA VALUES('48',44,49); +INSERT INTO MOCKDATA VALUES('49',38,5); +INSERT INTO MOCKDATA VALUES('50',21,31); + diff --git a/fake_data/backup/50/STAFF.sql b/fake_data/backup/50/STAFF.sql new file mode 100644 index 0000000..d9fae94 --- /dev/null +++ b/fake_data/backup/50/STAFF.sql @@ -0,0 +1,54 @@ +/*script generated for free with OnlineDataGenerator available at: https://www.onlinedatagenerator.com */ +CREATE TABLE MOCKDATA(stid BIGINT,stname VARCHAR(500)); + +INSERT INTO MOCKDATA VALUES('1','Henry'); +INSERT INTO MOCKDATA VALUES('2','Katelyn'); +INSERT INTO MOCKDATA VALUES('3','Olivia'); +INSERT INTO MOCKDATA VALUES('4','Chris'); +INSERT INTO MOCKDATA VALUES('5','Chris'); +INSERT INTO MOCKDATA VALUES('6','Rufus'); +INSERT INTO MOCKDATA VALUES('7','Ramon'); +INSERT INTO MOCKDATA VALUES('8','Jolene'); +INSERT INTO MOCKDATA VALUES('9','Denny'); +INSERT INTO MOCKDATA VALUES('10','William'); +INSERT INTO MOCKDATA VALUES('11','Callie'); +INSERT INTO MOCKDATA VALUES('12','Danny'); +INSERT INTO MOCKDATA VALUES('13','Susan'); +INSERT INTO MOCKDATA VALUES('14','Nick'); +INSERT INTO MOCKDATA VALUES('15','Liam'); +INSERT INTO MOCKDATA VALUES('16','Caleb'); +INSERT INTO MOCKDATA VALUES('17','Sebastian'); +INSERT INTO MOCKDATA VALUES('18','Clint'); +INSERT INTO MOCKDATA VALUES('19','Percy'); +INSERT INTO MOCKDATA VALUES('20','Parker'); +INSERT INTO MOCKDATA VALUES('21','Julian'); +INSERT INTO MOCKDATA VALUES('22','Grace'); +INSERT INTO MOCKDATA VALUES('23','Cassandra'); +INSERT INTO MOCKDATA VALUES('24','Denis'); +INSERT INTO MOCKDATA VALUES('25','Abdul'); +INSERT INTO MOCKDATA VALUES('26','Liam'); +INSERT INTO MOCKDATA VALUES('27','Cassidy'); +INSERT INTO MOCKDATA VALUES('28','Adeline'); +INSERT INTO MOCKDATA VALUES('29','Tiffany'); +INSERT INTO MOCKDATA VALUES('30','Kieth'); +INSERT INTO MOCKDATA VALUES('31','Elijah'); +INSERT INTO MOCKDATA VALUES('32','Keira'); +INSERT INTO MOCKDATA VALUES('33','Russel'); +INSERT INTO MOCKDATA VALUES('34','Chuck'); +INSERT INTO MOCKDATA VALUES('35','Fred'); +INSERT INTO MOCKDATA VALUES('36','Olivia'); +INSERT INTO MOCKDATA VALUES('37','Catherine'); +INSERT INTO MOCKDATA VALUES('38','Alex'); +INSERT INTO MOCKDATA VALUES('39','Denny'); +INSERT INTO MOCKDATA VALUES('40','Johnathan'); +INSERT INTO MOCKDATA VALUES('41','Zoe'); +INSERT INTO MOCKDATA VALUES('42','Roger'); +INSERT INTO MOCKDATA VALUES('43','Ramon'); +INSERT INTO MOCKDATA VALUES('44','Allison'); +INSERT INTO MOCKDATA VALUES('45','Ruby'); +INSERT INTO MOCKDATA VALUES('46','Johnny'); +INSERT INTO MOCKDATA VALUES('47','Iris'); +INSERT INTO MOCKDATA VALUES('48','Analise'); +INSERT INTO MOCKDATA VALUES('49','Nick'); +INSERT INTO MOCKDATA VALUES('50','Aileen'); + diff --git a/fake_data/backup/50/STUDENT.sql b/fake_data/backup/50/STUDENT.sql new file mode 100644 index 0000000..e2a02a5 --- /dev/null +++ b/fake_data/backup/50/STUDENT.sql @@ -0,0 +1,54 @@ +/*script generated for free with OnlineDataGenerator available at: https://www.onlinedatagenerator.com */ +CREATE TABLE MOCKDATA(sid BIGINT,sname VARCHAR(500)); + +INSERT INTO MOCKDATA VALUES('1','Adalie'); +INSERT INTO MOCKDATA VALUES('2','Tyson'); +INSERT INTO MOCKDATA VALUES('3','Domenic'); +INSERT INTO MOCKDATA VALUES('4','Karla'); +INSERT INTO MOCKDATA VALUES('5','Luke'); +INSERT INTO MOCKDATA VALUES('6','Darlene'); +INSERT INTO MOCKDATA VALUES('7','Caleb'); +INSERT INTO MOCKDATA VALUES('8','Denny'); +INSERT INTO MOCKDATA VALUES('9','Mya'); +INSERT INTO MOCKDATA VALUES('10','Melania'); +INSERT INTO MOCKDATA VALUES('11','Roger'); +INSERT INTO MOCKDATA VALUES('12','Melody'); +INSERT INTO MOCKDATA VALUES('13','Tony'); +INSERT INTO MOCKDATA VALUES('14','Luna'); +INSERT INTO MOCKDATA VALUES('15','Alexander'); +INSERT INTO MOCKDATA VALUES('16','Samara'); +INSERT INTO MOCKDATA VALUES('17','Tyler'); +INSERT INTO MOCKDATA VALUES('18','Chuck'); +INSERT INTO MOCKDATA VALUES('19','Carmella'); +INSERT INTO MOCKDATA VALUES('20','Nick'); +INSERT INTO MOCKDATA VALUES('21','Sylvia'); +INSERT INTO MOCKDATA VALUES('22','Harvey'); +INSERT INTO MOCKDATA VALUES('23','Matt'); +INSERT INTO MOCKDATA VALUES('24','Mason'); +INSERT INTO MOCKDATA VALUES('25','Mya'); +INSERT INTO MOCKDATA VALUES('26','Johnathan'); +INSERT INTO MOCKDATA VALUES('27','Morgan'); +INSERT INTO MOCKDATA VALUES('28','Esmeralda'); +INSERT INTO MOCKDATA VALUES('29','Russel'); +INSERT INTO MOCKDATA VALUES('30','Gil'); +INSERT INTO MOCKDATA VALUES('31','Anthony'); +INSERT INTO MOCKDATA VALUES('32','Manuel'); +INSERT INTO MOCKDATA VALUES('33','Sonya'); +INSERT INTO MOCKDATA VALUES('34','Mary'); +INSERT INTO MOCKDATA VALUES('35','Luke'); +INSERT INTO MOCKDATA VALUES('36','Manuel'); +INSERT INTO MOCKDATA VALUES('37','Iris'); +INSERT INTO MOCKDATA VALUES('38','Callie'); +INSERT INTO MOCKDATA VALUES('39','Ema'); +INSERT INTO MOCKDATA VALUES('40','Ron'); +INSERT INTO MOCKDATA VALUES('41','Bethany'); +INSERT INTO MOCKDATA VALUES('42','Nick'); +INSERT INTO MOCKDATA VALUES('43','Danny'); +INSERT INTO MOCKDATA VALUES('44','Oliver'); +INSERT INTO MOCKDATA VALUES('45','Anais'); +INSERT INTO MOCKDATA VALUES('46','Maxwell'); +INSERT INTO MOCKDATA VALUES('47','Ronald'); +INSERT INTO MOCKDATA VALUES('48','Karla'); +INSERT INTO MOCKDATA VALUES('49','Celia'); +INSERT INTO MOCKDATA VALUES('50','Mona'); + diff --git a/fake_data/parse.py b/fake_data/parse.py new file mode 100644 index 0000000..c342fbf --- /dev/null +++ b/fake_data/parse.py @@ -0,0 +1,82 @@ +from msilib import schema +import sys +from pathlib import Path + +# dataset_folder_names = ["100", "1000", "5000", "10000", "15000"] +dataset_folder_names = ["50"] +table_schemas = { + "STUDENT": [("sid", "int"), ("sname", "varchar(50)")], + "STAFF": [("stid", "int"), ("stname", "varchar(50)")], + "COURSE": [("cid", "int"), ("cname", "varchar(50)")], + "SECTION": [("secid", "int"), ("courseid", "int"), ("staffid", "int")], + "ENROLL": [("eid", "int"), ("studentid", "int"), ("sectionid", "int")] +} + +def updateCreateQuery(table_name): + current_schema = table_schemas[table_name] + result = f"CREATE TABLE {table_name} (" + for col_name, col_type in current_schema: + result += f"{col_name} {col_type}, " + result = result[:-2] + ")" + return result + +# currently, row index is '1', need to convert to 1 before inserting +# eg. ('1', 'a', 'b', 'c') -> (1, 'a', 'b', 'c') +# we can assume that the first column is always the id +def convertIndexToInt(query): + queries = query.split(",", 1) + row_index = queries[0][1:].replace("'", "") + return f"({row_index},{queries[1]}" + +def updateInsertQuery(query, table_name): + current_schema = table_schemas[table_name] + index = query.find("VALUES") + if index == -1: + print("Error: query does not contain VALUES") + sys.exit(1) + # -1 is used to remove the trailing ';' + query_after_values = f"VALUES{convertIndexToInt(query[index+6:-1])}" + query_before_values = f"INSERT INTO {table_name} (" + for col_name, _ in current_schema: + query_before_values += f"{col_name}, " + query_before_values = query_before_values[:-2] + ") " + return query_before_values + query_after_values + +def parse(query_file): + query_file = Path(query_file) + table_name = query_file.stem + if not query_file.exists(): + print("Error: query file does not exist") + sys.exit(1) + + # read file content + lines = query_file.read_text().splitlines() + updated_lines = [] + curr_line_num = 1 + for line in lines: + # skip first line, which is comment + if curr_line_num == 1: + pass + elif curr_line_num == 2: + updated_lines.append(updateCreateQuery(table_name)) + elif len(line) == 0: + pass + else: + updated_lines.append(updateInsertQuery(line, table_name)) + curr_line_num += 1 + + + # write to file and replace the cntent + query_file.write_text('\n'.join(updated_lines)) + print(f"Successfully updated query file {query_file}, {len(updated_lines)} lines updated") + +def main(root_folder_path): + for dataset_folder_name in dataset_folder_names: + dataset_folder_path = Path(root_folder_path) / dataset_folder_name + for file_name in table_schemas.keys(): + query_file_path = dataset_folder_path / f"{file_name}.sql" + parse(query_file_path) + +if __name__ == '__main__': + # python3 parse.py + main("C:\\Users\\Jiaxiang\\git\\cs3223-project\\fake_data") \ No newline at end of file From 703a1af717d9f4c6da67accc87fac68d527c9251 Mon Sep 17 00:00:00 2001 From: Jiaxiang Yu Date: Thu, 24 Mar 2022 19:54:47 +0800 Subject: [PATCH 2/7] add gradyear to student --- fake_data/50/STUDENT.sql | 102 ++++++++++++++++---------------- fake_data/backup/50/STUDENT.sql | 102 ++++++++++++++++---------------- fake_data/parse.py | 2 +- 3 files changed, 103 insertions(+), 103 deletions(-) diff --git a/fake_data/50/STUDENT.sql b/fake_data/50/STUDENT.sql index 87dee27..b8f7e70 100644 --- a/fake_data/50/STUDENT.sql +++ b/fake_data/50/STUDENT.sql @@ -1,51 +1,51 @@ -CREATE TABLE STUDENT (sid int, sname varchar(50)) -INSERT INTO STUDENT (sid, sname) VALUES(1,'Adalie') -INSERT INTO STUDENT (sid, sname) VALUES(2,'Tyson') -INSERT INTO STUDENT (sid, sname) VALUES(3,'Domenic') -INSERT INTO STUDENT (sid, sname) VALUES(4,'Karla') -INSERT INTO STUDENT (sid, sname) VALUES(5,'Luke') -INSERT INTO STUDENT (sid, sname) VALUES(6,'Darlene') -INSERT INTO STUDENT (sid, sname) VALUES(7,'Caleb') -INSERT INTO STUDENT (sid, sname) VALUES(8,'Denny') -INSERT INTO STUDENT (sid, sname) VALUES(9,'Mya') -INSERT INTO STUDENT (sid, sname) VALUES(10,'Melania') -INSERT INTO STUDENT (sid, sname) VALUES(11,'Roger') -INSERT INTO STUDENT (sid, sname) VALUES(12,'Melody') -INSERT INTO STUDENT (sid, sname) VALUES(13,'Tony') -INSERT INTO STUDENT (sid, sname) VALUES(14,'Luna') -INSERT INTO STUDENT (sid, sname) VALUES(15,'Alexander') -INSERT INTO STUDENT (sid, sname) VALUES(16,'Samara') -INSERT INTO STUDENT (sid, sname) VALUES(17,'Tyler') -INSERT INTO STUDENT (sid, sname) VALUES(18,'Chuck') -INSERT INTO STUDENT (sid, sname) VALUES(19,'Carmella') -INSERT INTO STUDENT (sid, sname) VALUES(20,'Nick') -INSERT INTO STUDENT (sid, sname) VALUES(21,'Sylvia') -INSERT INTO STUDENT (sid, sname) VALUES(22,'Harvey') -INSERT INTO STUDENT (sid, sname) VALUES(23,'Matt') -INSERT INTO STUDENT (sid, sname) VALUES(24,'Mason') -INSERT INTO STUDENT (sid, sname) VALUES(25,'Mya') -INSERT INTO STUDENT (sid, sname) VALUES(26,'Johnathan') -INSERT INTO STUDENT (sid, sname) VALUES(27,'Morgan') -INSERT INTO STUDENT (sid, sname) VALUES(28,'Esmeralda') -INSERT INTO STUDENT (sid, sname) VALUES(29,'Russel') -INSERT INTO STUDENT (sid, sname) VALUES(30,'Gil') -INSERT INTO STUDENT (sid, sname) VALUES(31,'Anthony') -INSERT INTO STUDENT (sid, sname) VALUES(32,'Manuel') -INSERT INTO STUDENT (sid, sname) VALUES(33,'Sonya') -INSERT INTO STUDENT (sid, sname) VALUES(34,'Mary') -INSERT INTO STUDENT (sid, sname) VALUES(35,'Luke') -INSERT INTO STUDENT (sid, sname) VALUES(36,'Manuel') -INSERT INTO STUDENT (sid, sname) VALUES(37,'Iris') -INSERT INTO STUDENT (sid, sname) VALUES(38,'Callie') -INSERT INTO STUDENT (sid, sname) VALUES(39,'Ema') -INSERT INTO STUDENT (sid, sname) VALUES(40,'Ron') -INSERT INTO STUDENT (sid, sname) VALUES(41,'Bethany') -INSERT INTO STUDENT (sid, sname) VALUES(42,'Nick') -INSERT INTO STUDENT (sid, sname) VALUES(43,'Danny') -INSERT INTO STUDENT (sid, sname) VALUES(44,'Oliver') -INSERT INTO STUDENT (sid, sname) VALUES(45,'Anais') -INSERT INTO STUDENT (sid, sname) VALUES(46,'Maxwell') -INSERT INTO STUDENT (sid, sname) VALUES(47,'Ronald') -INSERT INTO STUDENT (sid, sname) VALUES(48,'Karla') -INSERT INTO STUDENT (sid, sname) VALUES(49,'Celia') -INSERT INTO STUDENT (sid, sname) VALUES(50,'Mona') \ No newline at end of file +CREATE TABLE STUDENT (sid int, sname varchar(50), gradyear int) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(1,'Logan',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(2,'Chuck',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(3,'Julian',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(4,'Doug',2022) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(5,'Barry',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(6,'Chad',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(7,'Hank',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(8,'Carl',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(9,'Johnathan',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(10,'Harvey',2022) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(11,'Julian',2022) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(12,'Josh',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(13,'Jack',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(14,'Caleb',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(15,'Ryan',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(16,'Erick',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(17,'Alan',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(18,'Doug',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(19,'Danny',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(20,'Russel',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(21,'Rick',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(22,'Ronald',2022) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(23,'Nicholas',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(24,'Percy',2022) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(25,'Lucas',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(26,'Javier',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(27,'Wade',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(28,'William',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(29,'Ronald',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(30,'Daniel',2022) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(31,'Mike',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(32,'Barney',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(33,'Julius',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(34,'Mike',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(35,'Noah',2022) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(36,'Chad',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(37,'Nathan',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(38,'Liam',2022) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(39,'Chester',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(40,'Peter',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(41,'Aiden',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(42,'Carl',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(43,'Hayden',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(44,'Eduardo',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(45,'Maxwell',2023) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(46,'Benjamin',2022) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(47,'Johnny',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(48,'Owen',2024) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(49,'Logan',2025) +INSERT INTO STUDENT (sid, sname, gradyear) VALUES(50,'Chuck',2025) \ No newline at end of file diff --git a/fake_data/backup/50/STUDENT.sql b/fake_data/backup/50/STUDENT.sql index e2a02a5..b218ed0 100644 --- a/fake_data/backup/50/STUDENT.sql +++ b/fake_data/backup/50/STUDENT.sql @@ -1,54 +1,54 @@ /*script generated for free with OnlineDataGenerator available at: https://www.onlinedatagenerator.com */ -CREATE TABLE MOCKDATA(sid BIGINT,sname VARCHAR(500)); +CREATE TABLE MOCKDATA(sid BIGINT,sname VARCHAR(500),gradyear INT); -INSERT INTO MOCKDATA VALUES('1','Adalie'); -INSERT INTO MOCKDATA VALUES('2','Tyson'); -INSERT INTO MOCKDATA VALUES('3','Domenic'); -INSERT INTO MOCKDATA VALUES('4','Karla'); -INSERT INTO MOCKDATA VALUES('5','Luke'); -INSERT INTO MOCKDATA VALUES('6','Darlene'); -INSERT INTO MOCKDATA VALUES('7','Caleb'); -INSERT INTO MOCKDATA VALUES('8','Denny'); -INSERT INTO MOCKDATA VALUES('9','Mya'); -INSERT INTO MOCKDATA VALUES('10','Melania'); -INSERT INTO MOCKDATA VALUES('11','Roger'); -INSERT INTO MOCKDATA VALUES('12','Melody'); -INSERT INTO MOCKDATA VALUES('13','Tony'); -INSERT INTO MOCKDATA VALUES('14','Luna'); -INSERT INTO MOCKDATA VALUES('15','Alexander'); -INSERT INTO MOCKDATA VALUES('16','Samara'); -INSERT INTO MOCKDATA VALUES('17','Tyler'); -INSERT INTO MOCKDATA VALUES('18','Chuck'); -INSERT INTO MOCKDATA VALUES('19','Carmella'); -INSERT INTO MOCKDATA VALUES('20','Nick'); -INSERT INTO MOCKDATA VALUES('21','Sylvia'); -INSERT INTO MOCKDATA VALUES('22','Harvey'); -INSERT INTO MOCKDATA VALUES('23','Matt'); -INSERT INTO MOCKDATA VALUES('24','Mason'); -INSERT INTO MOCKDATA VALUES('25','Mya'); -INSERT INTO MOCKDATA VALUES('26','Johnathan'); -INSERT INTO MOCKDATA VALUES('27','Morgan'); -INSERT INTO MOCKDATA VALUES('28','Esmeralda'); -INSERT INTO MOCKDATA VALUES('29','Russel'); -INSERT INTO MOCKDATA VALUES('30','Gil'); -INSERT INTO MOCKDATA VALUES('31','Anthony'); -INSERT INTO MOCKDATA VALUES('32','Manuel'); -INSERT INTO MOCKDATA VALUES('33','Sonya'); -INSERT INTO MOCKDATA VALUES('34','Mary'); -INSERT INTO MOCKDATA VALUES('35','Luke'); -INSERT INTO MOCKDATA VALUES('36','Manuel'); -INSERT INTO MOCKDATA VALUES('37','Iris'); -INSERT INTO MOCKDATA VALUES('38','Callie'); -INSERT INTO MOCKDATA VALUES('39','Ema'); -INSERT INTO MOCKDATA VALUES('40','Ron'); -INSERT INTO MOCKDATA VALUES('41','Bethany'); -INSERT INTO MOCKDATA VALUES('42','Nick'); -INSERT INTO MOCKDATA VALUES('43','Danny'); -INSERT INTO MOCKDATA VALUES('44','Oliver'); -INSERT INTO MOCKDATA VALUES('45','Anais'); -INSERT INTO MOCKDATA VALUES('46','Maxwell'); -INSERT INTO MOCKDATA VALUES('47','Ronald'); -INSERT INTO MOCKDATA VALUES('48','Karla'); -INSERT INTO MOCKDATA VALUES('49','Celia'); -INSERT INTO MOCKDATA VALUES('50','Mona'); +INSERT INTO MOCKDATA VALUES('1','Logan',2025); +INSERT INTO MOCKDATA VALUES('2','Chuck',2025); +INSERT INTO MOCKDATA VALUES('3','Julian',2023); +INSERT INTO MOCKDATA VALUES('4','Doug',2022); +INSERT INTO MOCKDATA VALUES('5','Barry',2024); +INSERT INTO MOCKDATA VALUES('6','Chad',2025); +INSERT INTO MOCKDATA VALUES('7','Hank',2025); +INSERT INTO MOCKDATA VALUES('8','Carl',2023); +INSERT INTO MOCKDATA VALUES('9','Johnathan',2024); +INSERT INTO MOCKDATA VALUES('10','Harvey',2022); +INSERT INTO MOCKDATA VALUES('11','Julian',2022); +INSERT INTO MOCKDATA VALUES('12','Josh',2025); +INSERT INTO MOCKDATA VALUES('13','Jack',2024); +INSERT INTO MOCKDATA VALUES('14','Caleb',2025); +INSERT INTO MOCKDATA VALUES('15','Ryan',2024); +INSERT INTO MOCKDATA VALUES('16','Erick',2024); +INSERT INTO MOCKDATA VALUES('17','Alan',2023); +INSERT INTO MOCKDATA VALUES('18','Doug',2024); +INSERT INTO MOCKDATA VALUES('19','Danny',2023); +INSERT INTO MOCKDATA VALUES('20','Russel',2023); +INSERT INTO MOCKDATA VALUES('21','Rick',2025); +INSERT INTO MOCKDATA VALUES('22','Ronald',2022); +INSERT INTO MOCKDATA VALUES('23','Nicholas',2023); +INSERT INTO MOCKDATA VALUES('24','Percy',2022); +INSERT INTO MOCKDATA VALUES('25','Lucas',2024); +INSERT INTO MOCKDATA VALUES('26','Javier',2024); +INSERT INTO MOCKDATA VALUES('27','Wade',2025); +INSERT INTO MOCKDATA VALUES('28','William',2024); +INSERT INTO MOCKDATA VALUES('29','Ronald',2025); +INSERT INTO MOCKDATA VALUES('30','Daniel',2022); +INSERT INTO MOCKDATA VALUES('31','Mike',2025); +INSERT INTO MOCKDATA VALUES('32','Barney',2025); +INSERT INTO MOCKDATA VALUES('33','Julius',2024); +INSERT INTO MOCKDATA VALUES('34','Mike',2023); +INSERT INTO MOCKDATA VALUES('35','Noah',2022); +INSERT INTO MOCKDATA VALUES('36','Chad',2024); +INSERT INTO MOCKDATA VALUES('37','Nathan',2024); +INSERT INTO MOCKDATA VALUES('38','Liam',2022); +INSERT INTO MOCKDATA VALUES('39','Chester',2024); +INSERT INTO MOCKDATA VALUES('40','Peter',2025); +INSERT INTO MOCKDATA VALUES('41','Aiden',2023); +INSERT INTO MOCKDATA VALUES('42','Carl',2023); +INSERT INTO MOCKDATA VALUES('43','Hayden',2023); +INSERT INTO MOCKDATA VALUES('44','Eduardo',2023); +INSERT INTO MOCKDATA VALUES('45','Maxwell',2023); +INSERT INTO MOCKDATA VALUES('46','Benjamin',2022); +INSERT INTO MOCKDATA VALUES('47','Johnny',2024); +INSERT INTO MOCKDATA VALUES('48','Owen',2024); +INSERT INTO MOCKDATA VALUES('49','Logan',2025); +INSERT INTO MOCKDATA VALUES('50','Chuck',2025); diff --git a/fake_data/parse.py b/fake_data/parse.py index c342fbf..4fd46e1 100644 --- a/fake_data/parse.py +++ b/fake_data/parse.py @@ -5,7 +5,7 @@ # dataset_folder_names = ["100", "1000", "5000", "10000", "15000"] dataset_folder_names = ["50"] table_schemas = { - "STUDENT": [("sid", "int"), ("sname", "varchar(50)")], + "STUDENT": [("sid", "int"), ("sname", "varchar(50)"), ("gradyear", "int")], "STAFF": [("stid", "int"), ("stname", "varchar(50)")], "COURSE": [("cid", "int"), ("cname", "varchar(50)")], "SECTION": [("secid", "int"), ("courseid", "int"), ("staffid", "int")], From 5ec230e308cd7cba77f028e957201a802e3f9f9d Mon Sep 17 00:00:00 2001 From: Jiaxiang Yu Date: Thu, 24 Mar 2022 20:36:27 +0800 Subject: [PATCH 3/7] add demo utils and insertion code --- .../src/simpledb/demo/DemoUtils.java | 192 +++++++++++ SimpleDBEngine/src/simpledb/demo/RunDemo.java | 251 +++++++++++++++ .../experiment/ExperimentOneRunner.java | 54 ++++ .../simpledb/experiment/ExperimentUtils.java | 213 ++++++++++++ .../simpledb/experiment/RunExperiment.java | 303 ++++++++++++++++++ .../test/CreateStudentDBWithIndex.java | 4 +- .../src/simpledb/test/DistinctTest.java | 6 + .../src/simpledb/test/GeneralJoinTest.java | 123 +++---- .../src/simpledb/test/TestUtil.java | 55 +++- 9 files changed, 1139 insertions(+), 62 deletions(-) create mode 100644 SimpleDBEngine/src/simpledb/demo/DemoUtils.java create mode 100644 SimpleDBEngine/src/simpledb/demo/RunDemo.java create mode 100644 SimpleDBEngine/src/simpledb/experiment/ExperimentOneRunner.java create mode 100644 SimpleDBEngine/src/simpledb/experiment/ExperimentUtils.java create mode 100644 SimpleDBEngine/src/simpledb/experiment/RunExperiment.java diff --git a/SimpleDBEngine/src/simpledb/demo/DemoUtils.java b/SimpleDBEngine/src/simpledb/demo/DemoUtils.java new file mode 100644 index 0000000..b18925e --- /dev/null +++ b/SimpleDBEngine/src/simpledb/demo/DemoUtils.java @@ -0,0 +1,192 @@ +package simpledb.demo; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import simpledb.server.SimpleDB; +import simpledb.plan.Planner; +import simpledb.tx.Transaction; + +public class DemoUtils { + // Replace the path to your local absolute path + final static Path rootTestDataFolder = Path.of("C:\\Users\\Jiaxiang\\git\\cs3223-project\\fake_data"); + final static Path rootDbFolder = Path.of("C:\\Users\\Jiaxiang\\git\\cs3223-project"); + final static String[] filenames = {"STUDENT.sql", "COURSE.sql", "STAFF.sql", "ENROLL.sql", "SECTION.sql"}; + final static Map createHashIndexQueries = new HashMap(); + final static Map createBtreeIndexQueries = new HashMap(); + final static Map> createHashIndexQueriesMultiTable = new HashMap<>(); + final static Map> createBtreeIndexQueriesMultiTable = new HashMap<>(); + final static int max_inserts_per_transaction_for_index = 1; + + public static void InsertDemoDataSingleTable(String dataset_folder_name, String index_type) { + // if db_demo_{dataset_folder_name} exists, print warning and stop + if (new File(rootDbFolder.resolve("db_demo_index_" + index_type + "_" + dataset_folder_name).toString()).exists()) { + System.out.println("Warning: " + "db_demo_index_" + index_type + "_" + dataset_folder_name + " exists, skip inserting data"); + return; + } + InitCreateIndexQueriesSingleTable(); + SimpleDB db = new SimpleDB("db_demo_index_" + index_type + "_" + dataset_folder_name); + for (final String filename : filenames) { + InsertFileDataSingleTable(rootTestDataFolder.resolve(dataset_folder_name).resolve(filename), db, index_type); + } + } + + private static void InitCreateIndexQueriesSingleTable() { + // both will always be initialized together + if (!createHashIndexQueries.isEmpty()) { + return; + } + // Hash index + createHashIndexQueries.put("SECTION", "create index courseidh on section(courseid) using hash"); + // Btree index + createBtreeIndexQueries.put("SECTION", "create index courseidb on section(courseid) using btree"); + } + + private static void InsertFileDataSingleTable(Path file, SimpleDB db, String index_type) { + Planner planner = db.planner(); + Transaction tx = db.newTx(); + final String file_name = file.getFileName().toString(); + final String table_name = file_name.substring(0, file_name.lastIndexOf('.')); + BufferedReader reader; + String query; + int query_count = 0; + try { + reader = Files.newBufferedReader(file); + while ((query = reader.readLine()) != null) { + query_count++; + // create index on the id column after table is created + if (query_count == 2 && createHashIndexQueries.containsKey(table_name)) { + if (index_type.equals("hash")) { + planner.executeUpdate(createHashIndexQueries.get(table_name), tx); + } else if (index_type.equals("btree")) { + planner.executeUpdate(createBtreeIndexQueries.get(table_name), tx); + } + query_count++; + } + planner.executeUpdate(query, tx); + + // // Btree index cannot insert multiple values in one transcation + // // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts + // if (query_count % max_inserts_per_transaction_for_index == 0) { + // // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); + // tx.commit(); + // planner = db.planner(); + // tx = db.newTx(); + // } + } + reader.close(); + System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries with index type " + index_type); + } catch (IOException e) { + e.printStackTrace(); + } + tx.commit(); + } + + // For multi-table join demo. + public static void InsertDemoDataMultiTable(String dataset_folder_name, String index_type) { + // if db_demo_{dataset_folder_name} exists, print warning and stop + if (new File(rootDbFolder.resolve("db_demo_2_index_" + index_type + "_" + dataset_folder_name).toString()).exists()) { + System.out.println("Warning: " + "db_demo_2_index_" + index_type + "_" + dataset_folder_name + " exists, skip inserting data"); + return; + } + InitCreateIndexQueriesMultiTable(); + SimpleDB db = new SimpleDB("db_demo_2_index_" + index_type + "_" + dataset_folder_name); + for (final String filename : filenames) { + InsertFileDataWithIndexDemoTwo(rootTestDataFolder.resolve(dataset_folder_name).resolve(filename), db, index_type); + } + } + + private static void InitCreateIndexQueriesMultiTable() { + // both will always be initialized together + if (!createHashIndexQueriesMultiTable.isEmpty()) { + return; + } + // Hash index + List qry = new ArrayList<>(); + qry.add("create index sidh on student(sid) using hash"); + createHashIndexQueriesMultiTable.put("STUDENT", qry); + qry = new ArrayList<>(); + qry.add("create index stidh on staff(stid) using hash"); + createHashIndexQueriesMultiTable.put("STAFF", qry); + qry = new ArrayList<>(); + qry.add("create index studentidh on enroll(studentid) using hash"); + qry.add("create index sectionidh on enroll(sectionid) using hash"); + createHashIndexQueriesMultiTable.put("ENROLL", qry); + qry = new ArrayList<>(); + qry.add("create index staffidh on section(staffid) using hash"); + qry.add("create index secidh on section(secid) using hash"); + createHashIndexQueriesMultiTable.put("SECTION", qry); + + // Btree index + qry = new ArrayList<>(); + qry.add("create index sidb on student(sid) using btree"); + createBtreeIndexQueriesMultiTable.put("STUDENT", qry); + qry = new ArrayList<>(); + qry.add("create index stidb on staff(stid) using btree"); + createBtreeIndexQueriesMultiTable.put("STAFF", qry); + qry = new ArrayList<>(); + qry.add("create index studentidb on enroll(studentid) using btree"); + qry.add("create index sectionidb on enroll(sectionid) using btree"); + createBtreeIndexQueriesMultiTable.put("ENROLL", qry); + qry = new ArrayList<>(); + qry.add("create index staffidb on section(staffid) using btree"); + qry.add("create index secidb on section(secid) using btree"); + createBtreeIndexQueriesMultiTable.put("SECTION", qry); + } + + // For multi-table join demo. + private static void InsertFileDataWithIndexDemoTwo(Path file, SimpleDB db, String index_type) { + Planner planner = db.planner(); + Transaction tx = db.newTx(); + final String file_name = file.getFileName().toString(); + final String table_name = file_name.substring(0, file_name.lastIndexOf('.')); + BufferedReader reader; + String query; + int query_count = 0; + try { + reader = Files.newBufferedReader(file); + while ((query = reader.readLine()) != null) { + query_count++; + // create index on the id column after table is created + if (query_count == 2 && createHashIndexQueriesMultiTable.containsKey(table_name)) { + if (index_type.equals("hash")) { + for (String q : createHashIndexQueriesMultiTable.get(table_name)) { + planner.executeUpdate(q, tx); + query_count++; + } + } else if (index_type.equals("btree")) { + for (String q : createBtreeIndexQueriesMultiTable.get(table_name)) { + planner.executeUpdate(q, tx); + query_count++; + } + } else { + throw new RuntimeException("Index type " + index_type + " is not supported for table " + table_name); + } + } + planner.executeUpdate(query, tx); + + // // Btree index cannot insert multiple values in one transcation + // // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts + // if (query_count % max_inserts_per_transaction_for_index == 0) { + // // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); + // tx.commit(); + // planner = db.planner(); + // tx = db.newTx(); + // } + } + reader.close(); + System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries with index type " + index_type); + } catch (IOException e) { + e.printStackTrace(); + } + tx.commit(); + } + +} diff --git a/SimpleDBEngine/src/simpledb/demo/RunDemo.java b/SimpleDBEngine/src/simpledb/demo/RunDemo.java new file mode 100644 index 0000000..ab7a842 --- /dev/null +++ b/SimpleDBEngine/src/simpledb/demo/RunDemo.java @@ -0,0 +1,251 @@ +package simpledb.demo; + +import java.io.FileNotFoundException; +import java.io.PrintStream; +import java.sql.*; +import java.util.ArrayList; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import simpledb.jdbc.embedded.EmbeddedDriver; +import simpledb.server.SimpleDB; +import simpledb.test.TestUtil; + +public class RunDemo { + private static final String db_base_name = "db_demo_"; + private static final String db_base_name_demo_two = "db_demo_2_"; + private static final String[] num_of_rows_to_test = {"50"}; + private static final String[] index_types = {"hash", "btree"}; + // private static final String[] index_types = {"btree"}; + + public static void main(String[] args) throws FileNotFoundException { + // 1. Insert Demo data for single table + // db_demo_index_hash_50 will be created + // db_demo_index_btree_50 will be created + for (String index_type : index_types) { + InsertDataSingleTable(index_type); + } + + // 2. Insert Demo data for multi table join + // db_demo_2_index_hash_50 will be created + // db_demo_2_index_btree_50 will be created + for (String index_type : index_types) { + InsertDataMultiTable(index_type); + } + } + + private static void InsertDataSingleTable(String index_type) { + for (String n : num_of_rows_to_test) { + DemoUtils.InsertDemoDataSingleTable(n, index_type); + VerifyInsertSingleTable("index_" + index_type + "_" + n); + } + } + + private static void InsertDataMultiTable(String index_type) { + for (String n : num_of_rows_to_test) { + DemoUtils.InsertDemoDataMultiTable(n, index_type); + VerifyInsertMultiTable("index_" + index_type + "_" + n); + } + } + + // Select the count of ids for each of the tables + private static void VerifyInsertSingleTable(String db_child_name) { + SimpleDB db = new SimpleDB(db_base_name + db_child_name); + ExecuteVerifyInsert(db); + } + + private static void VerifyInsertMultiTable(String db_child_name) { + SimpleDB db = new SimpleDB(db_base_name_demo_two + db_child_name); + ExecuteVerifyInsert(db); + } + + private static void ExecuteVerifyInsert(SimpleDB db) { + String qry; + qry = "select count(sid) from student"; + TestUtil.executeQuery(qry, db); + qry = "select count(stid) from staff"; + TestUtil.executeQuery(qry, db); + qry = "select count(cid) from course"; + TestUtil.executeQuery(qry, db); + qry = "select count(secid) from section"; + TestUtil.executeQuery(qry, db); + qry = "select count(eid) from enroll"; + TestUtil.executeQuery(qry, db); + } + + + // Backup methods on running demo + // public static void main(String[] args) throws FileNotFoundException { + // Test with index + // for (String index_type : index_types) { + // for (String curr_num_of_rows_to_test : num_of_rows_to_test) { + // // InsertSingleDataWithIndex(index_type, curr_num_of_rows_to_test); + // RunDemoOneWithIndex(curr_num_of_rows_to_test, index_type); + // } + // } + + // // Test without Index, Experiement 2 + // for (String curr_num_of_rows_to_test : num_of_rows_to_test) { + // InsertSingleData(curr_num_of_rows_to_test); + // RunDemoTwo(curr_num_of_rows_to_test); + // } + + // // Test with index, Experiement 2 + // for (String index_type : index_types) { + // for (String curr_num_of_rows_to_test : num_of_rows_to_test) { + // InsertSingleDataWithIndexDemoTwo(index_type, curr_num_of_rows_to_test); + // RunDemoTwoWithIndex(curr_num_of_rows_to_test, index_type); + // } + // } + // } + + // private static void RunDemoOne(String db_child_name) { + // SimpleDB db = new SimpleDB(db_base_name + db_child_name); + // ExecuteDemoOne(db, db_child_name); + // } + + // private static void RunDemoOneWithIndex(String db_child_name, String index_type) { + // SimpleDB db = new SimpleDB(db_base_name + "index_" + index_type + "_" + db_child_name); + // ExecuteDemoOne(db, db_child_name); + // } + + // // Two-way join + // private static void ExecuteDemoOne(SimpleDB db, String db_child_name) { + // String qry; + // qry = "select sid, sname, eid, studentid from enroll, student where sid = studentid"; + // // Default to run the query 3 times and take average + // int n = 1; + // ArrayList times = new ArrayList(); + // for (int i = 0; i < n; i++) { + // long startTime = System.currentTimeMillis(); + // TestUtil.executeQuery(qry, db); + // long endTime = System.currentTimeMillis(); + // Double duration = (endTime - startTime) / 1000.0; + // times.add(duration); + // } + // Double avgTime = getAvarageTime(times); + // System.out.println("# of rows: "+ db_child_name + ", Query: " + qry ); + // System.out.println("Average time: " + avgTime + " s"); + // for (int i = 0; i < times.size(); i++) { + // System.out.println("Run#" + i + " Time: " + times.get(i) + " s"); + // } + // } + + // private static Double getAvarageTime(ArrayList times) { + // Double sum = 0.0; + // for (Double t : times) { + // sum += t; + // } + // return sum / times.size(); + // } + + // // 4 way join + // private static void RunDemoTwo(String db_child_name) { + // SimpleDB db = new SimpleDB(db_base_name + db_child_name); + // ExecuteDemoTwo(db, db_child_name); + // } + // // 4 way join with index + // private static void RunDemoTwoWithIndex(String db_child_name, String index_type) { + // SimpleDB db = new SimpleDB(db_base_name_demo_two + "index_" + index_type + "_" + db_child_name); + // ExecuteDemoTwo(db, db_child_name); + // } + + // private static void ExecuteDemoTwo(SimpleDB db, String db_child_name) { + // String qry; + // qry = "select sid, studentid, sectionid, secid, staffid, stid from student, enroll, section, staff where sid = studentid and sectionid = secid and staffid = stid"; + // // Default to run the query 3 times and take average + // int n = 1; + // ArrayList times = new ArrayList(); + // for (int i = 0; i < n; i++) { + // long startTime = System.currentTimeMillis(); + // TestUtil.executeQuery(qry, db); + // long endTime = System.currentTimeMillis(); + // Double duration = (endTime - startTime) / 1000.0; + // times.add(duration); + // } + // Double avgTime = getAvarageTime(times); + // System.out.println("# of rows: "+ db_child_name + ", Query: " + qry ); + // System.out.println("Average time: " + avgTime + " s"); + // for (int i = 0; i < times.size(); i++) { + // System.out.println("Run#" + i + " Time: " + times.get(i) + " s"); + // } + // } + + + // // Additional Methods that can be used + // private static void ExecuteDemoWithJDBC(String db_child_name, String index_type) { + // String url = "jdbc:simpledb:" + db_base_name + "index_" + index_type + "_" + db_child_name; + // String qry; + // qry = "select sid, sname, eid, studentid from enroll, student where sid = studentid"; + // // Default to run the query 3 times and take average + // int n = 1; + // ArrayList times = new ArrayList(); + // for (int j = 0; j < n; j++) { + // long startTime = System.currentTimeMillis(); + // ExecuteWithJDBC(url, qry); + // long endTime = System.currentTimeMillis(); + // Double duration = (endTime - startTime) / 1000.0; + // times.add(duration); + // } + + // Double avgTime = getAvarageTime(times); + // System.out.println("# of rows: "+ db_child_name + ", Query: " + qry ); + // System.out.println("Average time: " + avgTime + " s"); + // for (int i = 0; i < times.size(); i++) { + // System.out.println("Run#" + i + " Time: " + times.get(i) + " s"); + // } + // } + + // private static void ExecuteWithJDBC(String url, String qry) { + // Driver d = new EmbeddedDriver(); + // try (Connection conn = d.connect(url, null); + // Statement stmt = conn.createStatement(); + // ResultSet rs = stmt.executeQuery(qry)) { + + // ResultSetMetaData md = rs.getMetaData(); + // int numcols = md.getColumnCount(); + // int totalwidth = 0; + + // // print header + // for(int i=1; i<=numcols; i++) { + // String fldname = md.getColumnName(i); + // int width = md.getColumnDisplaySize(i); + // totalwidth += width; + // String fmt = "%" + width + "s"; + // System.out.format(fmt, fldname); + // } + // System.out.println(); + // for(int i=0; i times = new ArrayList(); + for (int i = 0; i < n; i++) { + long startTime = System.currentTimeMillis(); + TestUtil.executeQueryExperiment(qry, db); + long endTime = System.currentTimeMillis(); + Double duration = (endTime - startTime) / 1000.0; + times.add(duration); + } + Double avgTime = getAvarageTime(times); + System.out.println("# of rows: "+ db_child_name + ", Query: " + qry ); + System.out.println("Average time: " + avgTime + " s"); + for (int i = 0; i < times.size(); i++) { + System.out.println("Run#" + i + " Time: " + times.get(i) + " s"); + } + } + + private Double getAvarageTime(ArrayList times) { + Double sum = 0.0; + for (Double t : times) { + sum += t; + } + return sum / times.size(); + } + + @Override + public void run() { + while (!Thread.interrupted()) { + ExecuteExperimentOne(db, db_child_name); + // exit current thread + break; + } + } +} diff --git a/SimpleDBEngine/src/simpledb/experiment/ExperimentUtils.java b/SimpleDBEngine/src/simpledb/experiment/ExperimentUtils.java new file mode 100644 index 0000000..047e3f0 --- /dev/null +++ b/SimpleDBEngine/src/simpledb/experiment/ExperimentUtils.java @@ -0,0 +1,213 @@ +package simpledb.experiment; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import simpledb.server.SimpleDB; +import simpledb.plan.Planner; +import simpledb.tx.Transaction; + +public class ExperimentUtils { + // Replace the path to your local absolute path + final static Path rootTestDataFolder = Path.of("C:\\Users\\Jiaxiang\\git\\cs3223-project\\fake_data"); + final static Path rootDbFolder = Path.of("C:\\Users\\Jiaxiang\\git\\cs3223-project"); + final static String[] filenames = {"STUDENT.sql", "COURSE.sql", "STAFF.sql", "ENROLL.sql", "SECTION.sql"}; + final static Map createHashIndexQueries = new HashMap(); + final static Map createBtreeIndexQueries = new HashMap(); + final static Map> createHashIndexQueriesExperimentTwo = new HashMap<>(); + final static int max_inserts_per_transaction_for_index = 1; + + public static void InsertExperimentData(String dataset_folder_name) { + // if db_experiment_{dataset_folder_name} exists, print warning and stop + if (new File(rootDbFolder.resolve("db_experiment_" + dataset_folder_name).toString()).exists()) { + System.out.println("Warning: " + "db_experiment_" + dataset_folder_name + " exists, skip inserting data"); + return; + } + SimpleDB db = new SimpleDB("db_experiment_" + dataset_folder_name); + for (final String filename : filenames) { + InsertFileData(rootTestDataFolder.resolve(dataset_folder_name).resolve(filename), db); + } + } + + private static void InsertFileData(Path file, SimpleDB db) { + Planner planner = db.planner(); + Transaction tx = db.newTx(); + final String file_name = file.getFileName().toString(); + final String table_name = file_name.substring(0, file_name.lastIndexOf('.')); + BufferedReader reader; + String query; + int query_count = 0; + try { + reader = Files.newBufferedReader(file); + while ((query = reader.readLine()) != null) { + planner.executeUpdate(query, tx); + query_count++; + } + reader.close(); + System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); + } catch (IOException e) { + e.printStackTrace(); + } + tx.commit(); + } + + // Index will be added when data is inserted + // Index type can only be "hash" or "btree" + public static void InsertExperimentDataWithIndex(String dataset_folder_name, String index_type) { + // if db_experiment_{dataset_folder_name} exists, print warning and stop + if (new File(rootDbFolder.resolve("db_experiment_index_" + index_type + "_" + dataset_folder_name).toString()).exists()) { + System.out.println("Warning: " + "db_experiment_index_" + index_type + "_" + dataset_folder_name + " exists, skip inserting data"); + return; + } + InitCreateIndexQueries(); + SimpleDB db = new SimpleDB("db_experiment_index_" + index_type + "_" + dataset_folder_name); + for (final String filename : filenames) { + InsertFileDataWithIndex(rootTestDataFolder.resolve(dataset_folder_name).resolve(filename), db, index_type); + } + } + + private static void InitCreateIndexQueries() { + // both will always be initialized together + if (!createHashIndexQueries.isEmpty()) { + return; + } + // Hash index + createHashIndexQueries.put("STUDENT", "create index sidh on student(sid) using hash"); + createHashIndexQueries.put("STAFF", "create index stidh on staff(stid) using hash"); + createHashIndexQueries.put("ENROLL", "create index studentidh on enroll(studentid) using hash"); + createHashIndexQueries.put("SECTION", "create index staffidh on section(staffid) using hash"); + // Btree index + createBtreeIndexQueries.put("STUDENT", "create index sidb on student(sid) using btree"); + createBtreeIndexQueries.put("STAFF", "create index stidb on staff (stid) using btree"); + createBtreeIndexQueries.put("ENROLL", "create index studentidb on enroll(studentid) using btree"); + createBtreeIndexQueries.put("SECTION", "create index staffidb on section(staffid) using btree"); + } + + // Index will be added when data is inserted + private static void InsertFileDataWithIndex(Path file, SimpleDB db, String index_type) { + Planner planner = db.planner(); + Transaction tx = db.newTx(); + final String file_name = file.getFileName().toString(); + final String table_name = file_name.substring(0, file_name.lastIndexOf('.')); + BufferedReader reader; + String query; + int query_count = 0; + try { + reader = Files.newBufferedReader(file); + while ((query = reader.readLine()) != null) { + query_count++; + // create index on the id column after table is created + if (query_count == 2 && createHashIndexQueries.containsKey(table_name)) { + if (index_type.equals("hash")) { + planner.executeUpdate(createHashIndexQueries.get(table_name), tx); + } else if (index_type.equals("btree")) { + planner.executeUpdate(createBtreeIndexQueries.get(table_name), tx); + } + query_count++; + } + planner.executeUpdate(query, tx); + + // Btree index cannot insert multiple values in one transcation + // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts + if (query_count % max_inserts_per_transaction_for_index == 0) { + // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); + tx.commit(); + planner = db.planner(); + tx = db.newTx(); + } + } + reader.close(); + System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries with index type " + index_type); + } catch (IOException e) { + e.printStackTrace(); + } + tx.commit(); + } + + public static void InsertExperimentTwoDataWithIndex(String dataset_folder_name, String index_type) { + // if db_experiment_{dataset_folder_name} exists, print warning and stop + if (new File(rootDbFolder.resolve("db_experiment_2_index_" + index_type + "_" + dataset_folder_name).toString()).exists()) { + System.out.println("Warning: " + "db_experiment_2_index_" + index_type + "_" + dataset_folder_name + " exists, skip inserting data"); + return; + } + InitCreateIndexQueriesExperimentTwo(); + SimpleDB db = new SimpleDB("db_experiment_2_index_" + index_type + "_" + dataset_folder_name); + for (final String filename : filenames) { + InsertFileDataWithIndexExperimentTwo(rootTestDataFolder.resolve(dataset_folder_name).resolve(filename), db, index_type); + } + } + + + private static void InitCreateIndexQueriesExperimentTwo() { + // both will always be initialized together + if (!createHashIndexQueriesExperimentTwo.isEmpty()) { + return; + } + // Hash index + List qry = new ArrayList<>(); + qry.add("create index sidh on student(sid) using hash"); + createHashIndexQueriesExperimentTwo.put("STUDENT", qry); + qry = new ArrayList<>(); + qry.add("create index stidh on staff(stid) using hash"); + createHashIndexQueriesExperimentTwo.put("STAFF", qry); + qry = new ArrayList<>(); + qry.add("create index studentidh on enroll(studentid) using hash"); + qry.add("create index sectionidh on enroll(sectionid) using hash"); + createHashIndexQueriesExperimentTwo.put("ENROLL", qry); + qry = new ArrayList<>(); + qry.add("create index staffidh on section(staffid) using hash"); + qry.add("create index secidh on section(secid) using hash"); + createHashIndexQueriesExperimentTwo.put("SECTION", qry); + } + + // Index will be added when data is inserted + private static void InsertFileDataWithIndexExperimentTwo(Path file, SimpleDB db, String index_type) { + Planner planner = db.planner(); + Transaction tx = db.newTx(); + final String file_name = file.getFileName().toString(); + final String table_name = file_name.substring(0, file_name.lastIndexOf('.')); + BufferedReader reader; + String query; + int query_count = 0; + try { + reader = Files.newBufferedReader(file); + while ((query = reader.readLine()) != null) { + query_count++; + // create index on the id column after table is created + if (query_count == 2 && createHashIndexQueriesExperimentTwo.containsKey(table_name)) { + if (index_type.equals("hash")) { + for (String q : createHashIndexQueriesExperimentTwo.get(table_name)) { + planner.executeUpdate(q, tx); + query_count++; + } + } else { + throw new RuntimeException("Index type " + index_type + " is not supported for table " + table_name); + } + } + planner.executeUpdate(query, tx); + + // Btree index cannot insert multiple values in one transcation + // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts + if (query_count % max_inserts_per_transaction_for_index == 0) { + // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); + tx.commit(); + planner = db.planner(); + tx = db.newTx(); + } + } + reader.close(); + System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries with index type " + index_type); + } catch (IOException e) { + e.printStackTrace(); + } + tx.commit(); + } + +} diff --git a/SimpleDBEngine/src/simpledb/experiment/RunExperiment.java b/SimpleDBEngine/src/simpledb/experiment/RunExperiment.java new file mode 100644 index 0000000..63403a3 --- /dev/null +++ b/SimpleDBEngine/src/simpledb/experiment/RunExperiment.java @@ -0,0 +1,303 @@ +package simpledb.experiment; + +import java.io.FileNotFoundException; +import java.io.PrintStream; +import java.sql.*; +import java.util.ArrayList; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import simpledb.jdbc.embedded.EmbeddedDriver; +import simpledb.server.SimpleDB; +import simpledb.test.TestUtil; + +public class RunExperiment { + private static final String db_base_name = "db_experiment_"; + private static final String db_base_name_experiement_two = "db_experiment_2_"; + // private static final String[] num_of_rows_to_test = {"100", "1000", "5000", "10000", "15000"}; + // private static final String[] num_of_rows_to_test = {"10000", "15000"}; + private static final String[] num_of_rows_to_test = {"10000"}; + // private static final String[] index_types = {"hash", "btree"}; + private static final String[] index_types = {"btree"}; + private static final String output_base_path = "C:\\Users\\Jiaxiang\\git\\cs3223-project\\output"; + private static final int MAX_TIMEOUT = 10 * 60 * 1000; // 10 minutes + + public static void main(String[] args) throws FileNotFoundException { + + // Test with index + for (String index_type : index_types) { + for (String curr_num_of_rows_to_test : num_of_rows_to_test) { + PrintStream fileStream = new PrintStream(output_base_path+"\\"+curr_num_of_rows_to_test+"_"+ index_type +"_output.txt"); + System.setOut(fileStream); + // InsertSingleDataWithIndex(index_type, curr_num_of_rows_to_test); + RunExperimentOne(curr_num_of_rows_to_test, index_type); + } + } + + // // Test with index and timeout + // for (String index_type : index_types) { + // for (String curr_num_of_rows_to_test : num_of_rows_to_test) { + // PrintStream fileStream = new PrintStream(output_base_path+"\\"+curr_num_of_rows_to_test+"_"+ index_type +"_output.txt"); + // System.setOut(fileStream); + // // InsertSingleDataWithIndex(index_type, curr_num_of_rows_to_test); + // RunExperimentOneWithTimeout(curr_num_of_rows_to_test, index_type); + // } + // } + + // // Test without Index, Experiement 2 + // for (String curr_num_of_rows_to_test : num_of_rows_to_test) { + // PrintStream fileStream = new PrintStream(output_base_path+"\\"+curr_num_of_rows_to_test+"_output.txt"); + // System.setOut(fileStream); + // InsertSingleData(curr_num_of_rows_to_test); + // RunExperiementTwo(curr_num_of_rows_to_test); + // } + + // // Test with index, Experiement 2 + // for (String index_type : index_types) { + // for (String curr_num_of_rows_to_test : num_of_rows_to_test) { + // PrintStream fileStream = new PrintStream(output_base_path+"\\"+curr_num_of_rows_to_test+"_"+ index_type +"_output.txt"); + // System.setOut(fileStream); + // InsertSingleDataWithIndexExperimentTwo(index_type, curr_num_of_rows_to_test); + // RunExperimentTwo(curr_num_of_rows_to_test, index_type); + // } + // } + + } + + private static void Insert(String index_type) { + // without Index + // InsertAllData(); + // InsertSingleData(); + + // with Index + // InsertAllDataWithIndex(index_type); + // InsertSingleDataWithIndex(index_type); + } + + private static void InsertAllData() { + for (String n : num_of_rows_to_test) { + ExperimentUtils.InsertExperimentData(n); + VerifyInsert(n); + } + } + + private static void InsertSingleData(String current_num_of_rows) { + ExperimentUtils.InsertExperimentData(current_num_of_rows); + VerifyInsert(current_num_of_rows); + } + + private static void InsertAllDataWithIndex(String index_type) { + for (String n : num_of_rows_to_test) { + ExperimentUtils.InsertExperimentDataWithIndex(n, index_type); + VerifyInsertWithIndex("index_" + index_type + "_" + n); + } + } + + private static void InsertSingleDataWithIndex(String index_type, String current_num_of_rows) { + ExperimentUtils.InsertExperimentDataWithIndex(current_num_of_rows, index_type); + VerifyInsertWithIndex("index_" + index_type + "_" + current_num_of_rows); + } + + private static void InsertSingleDataWithIndexExperimentTwo(String index_type, String current_num_of_rows) { + ExperimentUtils.InsertExperimentTwoDataWithIndex(current_num_of_rows, index_type); + VerifyInsertWithIndexExperiementTwo("index_" + index_type + "_" + current_num_of_rows); + } + + // Select the count of ids for each of the tables + private static void VerifyInsert(String db_child_name) { + SimpleDB db = new SimpleDB(db_base_name + db_child_name); + ExecuteVerifyInsert(db); + } + + // Select the count of ids for each of the tables + private static void VerifyInsertWithIndex(String db_child_name) { + SimpleDB db = new SimpleDB(db_base_name + db_child_name); + ExecuteVerifyInsert(db); + } + + private static void VerifyInsertWithIndexExperiementTwo(String db_child_name) { + SimpleDB db = new SimpleDB(db_base_name_experiement_two + db_child_name); + ExecuteVerifyInsert(db); + } + + private static void ExecuteVerifyInsert(SimpleDB db) { + String qry; + qry = "select count(sid) from student"; + TestUtil.executeQuery(qry, db); + qry = "select count(stid) from staff"; + TestUtil.executeQuery(qry, db); + qry = "select count(cid) from course"; + TestUtil.executeQuery(qry, db); + qry = "select count(secid) from section"; + TestUtil.executeQuery(qry, db); + qry = "select count(eid) from enroll"; + TestUtil.executeQuery(qry, db); + } + + private static void RunExperimentOne(String db_child_name) { + SimpleDB db = new SimpleDB(db_base_name + db_child_name); + ExecuteExperimentOne(db, db_child_name); + } + + private static void RunExperimentOne(String db_child_name, String index_type) { + SimpleDB db = new SimpleDB(db_base_name + "index_" + index_type + "_" + db_child_name); + ExecuteExperimentOne(db, db_child_name); + } + + private static void ExecuteExperimentOne(SimpleDB db, String db_child_name) { + String qry; + qry = "select sid, sname, eid, studentid from enroll, student where sid = studentid"; + // Default to run the query 3 times and take average + int n = 3; + ArrayList times = new ArrayList(); + for (int i = 0; i < n; i++) { + long startTime = System.currentTimeMillis(); + TestUtil.executeQueryExperiment(qry, db); + long endTime = System.currentTimeMillis(); + Double duration = (endTime - startTime) / 1000.0; + times.add(duration); + } + Double avgTime = getAvarageTime(times); + System.out.println("# of rows: "+ db_child_name + ", Query: " + qry ); + System.out.println("Average time: " + avgTime + " s"); + for (int i = 0; i < times.size(); i++) { + System.out.println("Run#" + i + " Time: " + times.get(i) + " s"); + } + } + + private static Double getAvarageTime(ArrayList times) { + Double sum = 0.0; + for (Double t : times) { + sum += t; + } + return sum / times.size(); + } + + private static void RunExperimentOneWithTimeout(String db_child_name, String index_type) { + SimpleDB db = new SimpleDB(db_base_name + "index_" + index_type + "_" + db_child_name); + ExecutorService executor = Executors.newSingleThreadExecutor(); + Future future = executor.submit(new ExperimentOneRunner(db, db_child_name)); + try { + future.get(MAX_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (TimeoutException e) { + System.out.println("Timeout: " + db_base_name + "index_" + index_type + "_" + db_child_name); + future.cancel(true); + } catch (InterruptedException e) { + System.out.println("InterruptedException: " + db_base_name + "index_" + index_type + "_" + db_child_name); + e.printStackTrace(); + } catch (ExecutionException e) { + System.out.println("ExecutionException: " + db_base_name + "index_" + index_type + "_" + db_child_name); + e.printStackTrace(); + } finally { + executor.shutdownNow(); + } + } + + + private static void RunExperiementTwo(String db_child_name) { + SimpleDB db = new SimpleDB(db_base_name + db_child_name); + ExecuteExperimentTwo(db, db_child_name); + } + + private static void RunExperimentTwo(String db_child_name, String index_type) { + SimpleDB db = new SimpleDB(db_base_name_experiement_two + "index_" + index_type + "_" + db_child_name); + ExecuteExperimentTwo(db, db_child_name); + } + + private static void ExecuteExperimentTwo(SimpleDB db, String db_child_name) { + String qry; + qry = "select sid, studentid, sectionid, secid, staffid, stid from student, enroll, section, staff where sid = studentid and sectionid = secid and staffid = stid"; + // Default to run the query 3 times and take average + int n = 3; + ArrayList times = new ArrayList(); + for (int i = 0; i < n; i++) { + long startTime = System.currentTimeMillis(); + TestUtil.executeQueryExperiment(qry, db); + long endTime = System.currentTimeMillis(); + Double duration = (endTime - startTime) / 1000.0; + times.add(duration); + } + Double avgTime = getAvarageTime(times); + System.out.println("# of rows: "+ db_child_name + ", Query: " + qry ); + System.out.println("Average time: " + avgTime + " s"); + for (int i = 0; i < times.size(); i++) { + System.out.println("Run#" + i + " Time: " + times.get(i) + " s"); + } + } + + private static void ExecuteExperimentWithJDBC(String db_child_name, String index_type) { + String url = "jdbc:simpledb:" + db_base_name + "index_" + index_type + "_" + db_child_name; + String qry; + qry = "select sid, sname, eid, studentid from enroll, student where sid = studentid"; + // Default to run the query 3 times and take average + int n = 1; + ArrayList times = new ArrayList(); + for (int j = 0; j < n; j++) { + long startTime = System.currentTimeMillis(); + ExecuteWithJDBC(url, qry); + long endTime = System.currentTimeMillis(); + Double duration = (endTime - startTime) / 1000.0; + times.add(duration); + } + + Double avgTime = getAvarageTime(times); + System.out.println("# of rows: "+ db_child_name + ", Query: " + qry ); + System.out.println("Average time: " + avgTime + " s"); + for (int i = 0; i < times.size(); i++) { + System.out.println("Run#" + i + " Time: " + times.get(i) + " s"); + } + } + + private static void ExecuteWithJDBC(String url, String qry) { + Driver d = new EmbeddedDriver(); + try (Connection conn = d.connect(url, null); + Statement stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery(qry)) { + + ResultSetMetaData md = rs.getMetaData(); + int numcols = md.getColumnCount(); + int totalwidth = 0; + + // print header + for(int i=1; i<=numcols; i++) { + String fldname = md.getColumnName(i); + int width = md.getColumnDisplaySize(i); + totalwidth += width; + String fmt = "%" + width + "s"; + System.out.format(fmt, fldname); + } + System.out.println(); + for(int i=0; i operator, one predicate - qry = "select sid, sname, majorid, did, dname from student, dept where majorid > did"; - TestUtil.executeQuery(qry, db); - // <= operator, one predicate - qry = "select sid, sname, majorid, did, dname from student, dept where majorid <= did"; - TestUtil.executeQuery(qry, db); - // > and <, two predicates - qry = "select sid, sname, majorid, did, dname from student, dept where majorid > did and sid < did"; - TestUtil.executeQuery(qry, db); - // switched table order, two predicates - qry = "select sid, sname, majorid, did, dname from dept, student where majorid > did and sid < did"; - TestUtil.executeQuery(qry, db); + // // Section B. with non-equality operators only + // // != operator, one predicate + // qry = "select sid, sname, majorid, did, dname from student, dept where majorid != did"; + // TestUtil.executeQuery(qry, db); + // // != operator, two predicate + // qry = "select sid, sname, majorid, did, dname from student, dept where majorid != did and sname != dname"; + // TestUtil.executeQuery(qry, db); + // // > operator, one predicate + // qry = "select sid, sname, majorid, did, dname from student, dept where majorid > did"; + // TestUtil.executeQuery(qry, db); + // // <= operator, one predicate + // qry = "select sid, sname, majorid, did, dname from student, dept where majorid <= did"; + // TestUtil.executeQuery(qry, db); + // // > and <, two predicates + // qry = "select sid, sname, majorid, did, dname from student, dept where majorid > did and sid < did"; + // TestUtil.executeQuery(qry, db); + // // switched table order, two predicates + // qry = "select sid, sname, majorid, did, dname from dept, student where majorid > did and sid < did"; + // TestUtil.executeQuery(qry, db); - // Section C. with mixed = and non-equality operators - // = and !=, two predicates - qry = "select sid, sname, majorid, did, dname from student, dept where majorid = did and sid != did"; - TestUtil.executeQuery(qry, db); - // = and >, two predicates, did and sid order are swapped - qry = "select sid, sname, majorid, did, dname from student, dept where majorid = did and did > sid"; - TestUtil.executeQuery(qry, db); - // = and <, three predicates, Invalid case - // qry = "select sid, sname, majorid, did, dname from student, dept where majorid = did and did < sid and sid = did"; - // TestUtil.executeSelectQuery(qry, tx, planner, fieldNameAndType); + // // Section C. with mixed = and non-equality operators + // // = and !=, two predicates + // qry = "select sid, sname, majorid, did, dname from student, dept where majorid = did and sid != did"; + // TestUtil.executeQuery(qry, db); + // // = and >, two predicates, did and sid order are swapped + // qry = "select sid, sname, majorid, did, dname from student, dept where majorid = did and did > sid"; + // TestUtil.executeQuery(qry, db); + // // = and <, three predicates, Invalid case + // // qry = "select sid, sname, majorid, did, dname from student, dept where majorid = did and did < sid and sid = did"; + // // TestUtil.executeSelectQuery(qry, tx, planner, fieldNameAndType); - // Section D. with multiple tables and mixed join operators - // =, three predicates, three tables (student, dept, course) - qry = "select sid, sname, majorid, did, dname, title from student, dept, course where majorid = did and did = deptid"; - TestUtil.executeQuery(qry, db); + // // Section D. with multiple tables and mixed join operators + // // =, three predicates, three tables (student, dept, course) + // qry = "select sid, sname, majorid, did, dname, title from student, dept, course where majorid = did and did = deptid"; + // TestUtil.executeQuery(qry, db); - // =, three predicate, three tables (student, enroll, section) - qry = "select sname, grade, sid, studentid, sectionid, sectid from student, enroll, section where sid = studentid and sectionid = sectid"; - TestUtil.executeQuery(qry, db); + // // =, three predicate, three tables (student, enroll, section) + // qry = "select sname, grade, sid, studentid, sectionid, sectid from student, enroll, section where sid = studentid and sectionid = sectid"; + // TestUtil.executeQuery(qry, db); - // =, four predicate, four tables (student, enroll, section, course) - qry = "select sname, grade, sid, studentid, sectionid, sectid, courseid, cid, title from student, enroll, section, course where sid = studentid and sectionid = sectid and courseid = cid"; - TestUtil.executeQuery(qry, db); + // // =, four predicate, four tables (student, enroll, section, course) + // qry = "select sname, grade, sid, studentid, sectionid, sectid, courseid, cid, title from student, enroll, section, course where sid = studentid and sectionid = sectid and courseid = cid"; + // TestUtil.executeQuery(qry, db); - // =, five predicate, five tables (student, enroll, section, course, dept) - qry = "select sname, grade, sid, studentid, sectionid, sectid, courseid, cid, title, deptid, did, dname from student, enroll, section, course, dept where sid = studentid and sectionid = sectid and courseid = cid and deptid = did"; - TestUtil.executeQuery(qry, db); + // // =, five predicate, five tables (student, enroll, section, course, dept) + // qry = "select sname, grade, sid, studentid, sectionid, sectid, courseid, cid, title, deptid, did, dname from student, enroll, section, course, dept where sid = studentid and sectionid = sectid and courseid = cid and deptid = did"; + // TestUtil.executeQuery(qry, db); - // =, five predicate, five tables (student, enroll, section, course, dept), and a non-join related predicate - qry = "select sname, grade, sid, studentid, sectionid, sectid, courseid, cid, title, deptid, did, dname from student, enroll, section, course, dept where sid = studentid and sectionid = sectid and courseid = cid and deptid = did and deptid > 20"; - TestUtil.executeQuery(qry, db); + // // =, five predicate, five tables (student, enroll, section, course, dept), and a non-join related predicate + // qry = "select sname, grade, sid, studentid, sectionid, sectid, courseid, cid, title, deptid, did, dname from student, enroll, section, course, dept where sid = studentid and sectionid = sectid and courseid = cid and deptid = did and deptid > 20"; + // TestUtil.executeQuery(qry, db); - // mixed operators, five tables - qry = "select sname, grade, sid, studentid, sectionid, sectid, courseid, cid, title, deptid, did, dname from student, enroll, section, course, dept where sid = studentid and sectionid < sectid and courseid >= cid and deptid != did and sid = 1"; - TestUtil.executeQuery(qry, db); + // // mixed operators, five tables + // qry = "select sname, grade, sid, studentid, sectionid, sectid, courseid, cid, title, deptid, did, dname from student, enroll, section, course, dept where sid = studentid and sectionid < sectid and courseid >= cid and deptid != did and sid = 1"; + // TestUtil.executeQuery(qry, db); + + // // selected fields are not used in where clause + // qry = "select sname, grade from student, enroll, section, course, dept where sid = studentid and sectionid = sectid and courseid = cid and deptid = did"; + // TestUtil.executeQuery(qry, db); - // selected fields are not used in where clause - qry = "select sname, grade from student, enroll, section, course, dept where sid = studentid and sectionid = sectid and courseid = cid and deptid = did"; + // TODO: delete before final submission + // qry = "select sname, grade, sid, studentid, sectionid, sectid, courseid, cid, title, deptid, did, dname from student, enroll, section, course, dept where sid = studentid and sectionid = sectid and courseid = cid and deptid = did"; + // TestUtil.executeQuery(qry, db); + // =, four predicate, four tables (student, enroll, section, course) + qry = "select sname, grade, sid, studentid, sectionid, sectid, courseid, cid, title from student, enroll, section, course where sid = studentid and sectionid = sectid and courseid = cid"; TestUtil.executeQuery(qry, db); + // qry = "select sid, sname, majorid, did, dname from student, dept where majorid = did"; + // TestUtil.executeQuery(qry, db); + // qry = "select sname, grade, sid, studentid, sectionid, sectid from student, enroll, section where sid = studentid and sectionid = sectid"; + // TestUtil.executeQuery(qry, db); } catch(Exception e) { e.printStackTrace(); diff --git a/SimpleDBEngine/src/simpledb/test/TestUtil.java b/SimpleDBEngine/src/simpledb/test/TestUtil.java index a1f64c9..9b8b452 100644 --- a/SimpleDBEngine/src/simpledb/test/TestUtil.java +++ b/SimpleDBEngine/src/simpledb/test/TestUtil.java @@ -26,6 +26,7 @@ private static void doQuery(String cmd, Transaction tx, Planner planner) { ResultSetMetaData md = new EmbeddedMetaData(sch); int numcols = md.getColumnCount(); int totalwidth = 0; + int totalOutputReturned = 0; // print header for(int i=1; i<=numcols; i++) { @@ -47,16 +48,18 @@ private static void doQuery(String cmd, Transaction tx, Planner planner) { int fldtype = md.getColumnType(i); String fmt = "%" + md.getColumnDisplaySize(i); if (fldtype == Types.INTEGER) { - int ival = s.getInt(fldname); - System.out.format(fmt + "d", ival); + int ival = s.getInt(fldname); + System.out.format(fmt + "d", ival); } else { - String sval = s.getString(fldname); - System.out.format(fmt + "s", sval); + String sval = s.getString(fldname); + System.out.format(fmt + "s", sval); } } System.out.println(); + totalOutputReturned++; } + System.out.println("Total number of records returned: " + totalOutputReturned); s.close(); tx.commit(); } @@ -65,6 +68,50 @@ private static void doQuery(String cmd, Transaction tx, Planner planner) { } } + public static void executeQueryExperiment(String query, SimpleDB db) { + Transaction tx = db.newTx(); + Planner planner = db.planner(); + doQueryExperiment(query, tx, planner); + } + + // Minimise printing to user console + private static void doQueryExperiment(String cmd, Transaction tx, Planner planner) { + try { + // System.out.println(cmd); + Plan p = planner.createQueryPlan(cmd, tx); + Scan s = p.open(); + Schema sch = p.schema(); + ResultSetMetaData md = new EmbeddedMetaData(sch); + int numcols = md.getColumnCount(); + int totalwidth = 0; + int totalOutputReturned = 0; + + //execute + while(s.next()) { + for (int i=1; i<=numcols; i++) { + String fldname = md.getColumnName(i); + int fldtype = md.getColumnType(i); + String fmt = "%" + md.getColumnDisplaySize(i); + if (fldtype == Types.INTEGER) { + int ival = s.getInt(fldname); + // System.out.format(fmt + "d", ival); + } + else { + String sval = s.getString(fldname); + // System.out.format(fmt + "s", sval); + } + } + // System.out.println(); + totalOutputReturned++; + } + System.out.println("Total number of records returned: " + totalOutputReturned); + s.close(); + tx.commit(); + } + catch (Exception e) { + e.printStackTrace(); + } + } public static void createSampleStudentDBWithoutIndex(Planner planner, Transaction tx) { String s = "create table STUDENT(SId int, SName varchar(10), MajorId int, GradYear int)"; From d59512d4b71940685a2d8138ccd28cb1581791cf Mon Sep 17 00:00:00 2001 From: Jiaxiang Yu Date: Thu, 24 Mar 2022 20:39:16 +0800 Subject: [PATCH 4/7] enable tranx commit per one query --- .../src/simpledb/demo/DemoUtils.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/SimpleDBEngine/src/simpledb/demo/DemoUtils.java b/SimpleDBEngine/src/simpledb/demo/DemoUtils.java index b18925e..263f283 100644 --- a/SimpleDBEngine/src/simpledb/demo/DemoUtils.java +++ b/SimpleDBEngine/src/simpledb/demo/DemoUtils.java @@ -72,14 +72,14 @@ private static void InsertFileDataSingleTable(Path file, SimpleDB db, String ind } planner.executeUpdate(query, tx); - // // Btree index cannot insert multiple values in one transcation - // // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts - // if (query_count % max_inserts_per_transaction_for_index == 0) { - // // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); - // tx.commit(); - // planner = db.planner(); - // tx = db.newTx(); - // } + // Btree index cannot insert multiple values in one transcation + // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts + if (query_count % max_inserts_per_transaction_for_index == 0) { + // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); + tx.commit(); + planner = db.planner(); + tx = db.newTx(); + } } reader.close(); System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries with index type " + index_type); @@ -172,14 +172,14 @@ private static void InsertFileDataWithIndexDemoTwo(Path file, SimpleDB db, Strin } planner.executeUpdate(query, tx); - // // Btree index cannot insert multiple values in one transcation - // // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts - // if (query_count % max_inserts_per_transaction_for_index == 0) { - // // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); - // tx.commit(); - // planner = db.planner(); - // tx = db.newTx(); - // } + // Btree index cannot insert multiple values in one transcation + // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts + if (query_count % max_inserts_per_transaction_for_index == 0) { + // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); + tx.commit(); + planner = db.planner(); + tx = db.newTx(); + } } reader.close(); System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries with index type " + index_type); From 6a4a35a57258d7b39bba4c00b139d104a3a1f502 Mon Sep 17 00:00:00 2001 From: yuming7144 Date: Thu, 24 Mar 2022 22:17:29 +0800 Subject: [PATCH 5/7] fix typo --- SimpleDBEngine/src/simpledb/server/SimpleDB.java | 2 +- fake_data/50/ENROLL.sql | 4 ++-- fake_data/50/SECTION.sql | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SimpleDBEngine/src/simpledb/server/SimpleDB.java b/SimpleDBEngine/src/simpledb/server/SimpleDB.java index cb78a9f..74f63b8 100644 --- a/SimpleDBEngine/src/simpledb/server/SimpleDB.java +++ b/SimpleDBEngine/src/simpledb/server/SimpleDB.java @@ -17,7 +17,7 @@ */ public class SimpleDB { public static int BLOCK_SIZE = 400; - public static int BUFFER_SIZE = 8; + public static int BUFFER_SIZE = 400; public static String LOG_FILE = "simpledb.log"; private FileMgr fm; diff --git a/fake_data/50/ENROLL.sql b/fake_data/50/ENROLL.sql index 8673d7f..95bf144 100644 --- a/fake_data/50/ENROLL.sql +++ b/fake_data/50/ENROLL.sql @@ -1,6 +1,6 @@ CREATE TABLE ENROLL (eid int, studentid int, sectionid int) INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(1,4,28) -INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(2,2,42) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(2,1,42) INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(3,24,39) INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(4,35,4) INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(5,5,38) @@ -19,7 +19,7 @@ INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(17,37,12) INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(18,2,37) INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(19,42,46) INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(20,35,23) -INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(21,40,2) +INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(21,40,1) INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(22,47,43) INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(23,28,27) INSERT INTO ENROLL (eid, studentid, sectionid) VALUES(24,20,17) diff --git a/fake_data/50/SECTION.sql b/fake_data/50/SECTION.sql index baf2b44..82f587e 100644 --- a/fake_data/50/SECTION.sql +++ b/fake_data/50/SECTION.sql @@ -30,7 +30,7 @@ INSERT INTO SECTION (secid, courseid, staffid) VALUES(28,49,12) INSERT INTO SECTION (secid, courseid, staffid) VALUES(29,43,43) INSERT INTO SECTION (secid, courseid, staffid) VALUES(30,31,30) INSERT INTO SECTION (secid, courseid, staffid) VALUES(31,13,47) -INSERT INTO SECTION (secid, courseid, staffid) VALUES(32,17,3) +INSERT INTO SECTION (secid, courseid, staffid) VALUES(32,17,1) INSERT INTO SECTION (secid, courseid, staffid) VALUES(33,32,33) INSERT INTO SECTION (secid, courseid, staffid) VALUES(34,8,39) INSERT INTO SECTION (secid, courseid, staffid) VALUES(35,21,38) From d538f73db416beac3a054732cc60d713c6bdc0e0 Mon Sep 17 00:00:00 2001 From: yuming7144 Date: Thu, 24 Mar 2022 22:26:43 +0800 Subject: [PATCH 6/7] fix another typo --- SimpleDBEngine/src/simpledb/server/SimpleDB.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimpleDBEngine/src/simpledb/server/SimpleDB.java b/SimpleDBEngine/src/simpledb/server/SimpleDB.java index 74f63b8..ffe0816 100644 --- a/SimpleDBEngine/src/simpledb/server/SimpleDB.java +++ b/SimpleDBEngine/src/simpledb/server/SimpleDB.java @@ -17,7 +17,7 @@ */ public class SimpleDB { public static int BLOCK_SIZE = 400; - public static int BUFFER_SIZE = 400; + public static int BUFFER_SIZE = 100; public static String LOG_FILE = "simpledb.log"; private FileMgr fm; From dd8ba01c2563963ec00ec291cb5b28b56f9f66d7 Mon Sep 17 00:00:00 2001 From: Jiaxiang Yu Date: Fri, 25 Mar 2022 17:23:00 +0800 Subject: [PATCH 7/7] fix transcation print output --- .../src/simpledb/demo/DemoUtils.java | 32 +++++++++---------- .../src/simpledb/test/TestUtil.java | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/SimpleDBEngine/src/simpledb/demo/DemoUtils.java b/SimpleDBEngine/src/simpledb/demo/DemoUtils.java index 263f283..b18925e 100644 --- a/SimpleDBEngine/src/simpledb/demo/DemoUtils.java +++ b/SimpleDBEngine/src/simpledb/demo/DemoUtils.java @@ -72,14 +72,14 @@ private static void InsertFileDataSingleTable(Path file, SimpleDB db, String ind } planner.executeUpdate(query, tx); - // Btree index cannot insert multiple values in one transcation - // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts - if (query_count % max_inserts_per_transaction_for_index == 0) { - // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); - tx.commit(); - planner = db.planner(); - tx = db.newTx(); - } + // // Btree index cannot insert multiple values in one transcation + // // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts + // if (query_count % max_inserts_per_transaction_for_index == 0) { + // // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); + // tx.commit(); + // planner = db.planner(); + // tx = db.newTx(); + // } } reader.close(); System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries with index type " + index_type); @@ -172,14 +172,14 @@ private static void InsertFileDataWithIndexDemoTwo(Path file, SimpleDB db, Strin } planner.executeUpdate(query, tx); - // Btree index cannot insert multiple values in one transcation - // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts - if (query_count % max_inserts_per_transaction_for_index == 0) { - // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); - tx.commit(); - planner = db.planner(); - tx = db.newTx(); - } + // // Btree index cannot insert multiple values in one transcation + // // We commit and start a new transaction after {max_inserts_per_transaction_for_index} inserts + // if (query_count % max_inserts_per_transaction_for_index == 0) { + // // System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries"); + // tx.commit(); + // planner = db.planner(); + // tx = db.newTx(); + // } } reader.close(); System.out.println("Inserted data from file " + file_name + " into table " + table_name + " with " + query_count + " queries with index type " + index_type); diff --git a/SimpleDBEngine/src/simpledb/test/TestUtil.java b/SimpleDBEngine/src/simpledb/test/TestUtil.java index 9b8b452..a0c287c 100644 --- a/SimpleDBEngine/src/simpledb/test/TestUtil.java +++ b/SimpleDBEngine/src/simpledb/test/TestUtil.java @@ -59,7 +59,7 @@ private static void doQuery(String cmd, Transaction tx, Planner planner) { System.out.println(); totalOutputReturned++; } - System.out.println("Total number of records returned: " + totalOutputReturned); + // System.out.println("Total number of records returned: " + totalOutputReturned); s.close(); tx.commit(); }