· 7 years ago · Nov 07, 2018, 02:40 PM
1#include <iostream>
2#include <string>
3#include <vector>
4#include "sqlite3.h"
5
6using namespace std;
7
8void initializeDB(sqlite3 * db)
9{
10 sqlite3_stmt* myStatement;
11
12 int adviserPrep = sqlite3_prepare_v2(db, "CREATE TABLE IF NOT EXISTS Advisers (adviserID INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT)", -1, &myStatement, NULL);
13
14 if (adviserPrep == SQLITE_OK)
15 {
16 int adviserStep = sqlite3_step(myStatement);
17
18 if (adviserStep == SQLITE_DONE)
19 {
20 //cout << "Successfully created the the Advisers table" << endl;
21 }
22 else
23 {
24 cout << "Problem creating the Advisers table" << endl;
25 }
26 sqlite3_finalize(myStatement);
27 }
28 else
29 {
30 cout << "Problem creating a prepared statement" << endl;
31 }
32
33 int coursePrep = sqlite3_prepare_v2(db, "CREATE TABLE IF NOT EXISTS Courses (courseID INTEGER PRIMARY KEY, courseNumber TEXT, courseName TEXT, numberOfCredits INTEGER, isRequired TEXT, coursePrerequisites TEXT)", -1, &myStatement, NULL);
34
35 if (coursePrep == SQLITE_OK)
36 {
37 int courseStep = sqlite3_step(myStatement);
38
39 if (courseStep == SQLITE_DONE)
40 {
41 //cout << "Successfully created the the Courses table" << endl;
42 }
43 else
44 {
45 cout << "Problem creating the Courses table" << endl;
46 }
47 sqlite3_finalize(myStatement);
48 }
49 else
50 {
51 cout << "Problem creating a prepared statement" << endl;
52 }
53
54 int planPrep = sqlite3_prepare_v2(db, "CREATE TABLE IF NOT EXISTS Plans (planID INTEGER PRIMARY KEY, semesterAndYear TEXT, adviserID INTEGER, studentID INTEGER, FOREIGN KEY(adviserID) REFERENCES Advisers(adviserID), FOREIGN KEY(studentID) REFERENCES Students(studentID))", -1, &myStatement, NULL);
55
56 if (planPrep == SQLITE_OK)
57 {
58 int planStep = sqlite3_step(myStatement);
59
60 if (planStep == SQLITE_DONE)
61 {
62 //cout << "Successfully created the the Plans table" << endl;
63 }
64 else
65 {
66 cout << "Problem creating the Plans table" << endl;
67 }
68 sqlite3_finalize(myStatement);
69 }
70 else
71 {
72 cout << "Problem creating a prepared statement" << endl;
73 }
74
75 int studentPrep = sqlite3_prepare_v2(db, "CREATE TABLE IF NOT EXISTS Students (studentID INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT)", -1, &myStatement, NULL);
76
77 if (studentPrep == SQLITE_OK)
78 {
79 int studentStep = sqlite3_step(myStatement);
80
81 if (studentStep == SQLITE_DONE)
82 {
83 //cout << "Successfully created the the Students table" << endl;
84 }
85 else
86 {
87 cout << "Problem creating the Students table" << endl;
88 }
89 sqlite3_finalize(myStatement);
90 }
91 else
92 {
93 cout << "Problem creating a prepared statement" << endl;
94 }
95
96 int studentTakesClassesPrep = sqlite3_prepare_v2(db, "CREATE TABLE IF NOT EXISTS StudentTakesCourses (studentID INTEGER, courseID INTEGER, semesterAndYear TEXT, FOREIGN KEY(studentID) REFERENCES Students(studentID), FOREIGN KEY(courseID) REFERENCES Courses(courseID))", -1, &myStatement, NULL);
97
98 if (studentTakesClassesPrep == SQLITE_OK)
99 {
100 int studentTakesClassesStep = sqlite3_step(myStatement);
101
102 if (studentTakesClassesStep == SQLITE_DONE)
103 {
104 //cout << "Successfully created the the StudentTakesCourses table" << endl;
105 }
106 else
107 {
108 cout << "Problem creating the StudentTakesCourses table" << endl;
109 }
110 sqlite3_finalize(myStatement);
111 }
112 else
113 {
114 cout << "Problem creating a prepared statement" << endl;
115 }
116
117 int planHasCoursesPrep = sqlite3_prepare_v2(db, "CREATE TABLE IF NOT EXISTS PlanHasCourses (planID INTEGER, courseID INTEGER, FOREIGN KEY(planID) REFERENCES Plans(planID), FOREIGN KEY(courseID) REFERENCES Courses(courseID))", -1, &myStatement, NULL);
118
119 if (planHasCoursesPrep == SQLITE_OK)
120 {
121 int planHasCoursesStep = sqlite3_step(myStatement);
122
123 if (planHasCoursesStep == SQLITE_DONE)
124 {
125 //cout << "Successfully created the the PlanHasCourses table" << endl;
126 }
127 else
128 {
129 cout << "Problem creating the PlanHasCourses table" << endl;
130 }
131 sqlite3_finalize(myStatement);
132 }
133 else
134 {
135 cout << "Problem creating a prepared statement" << endl;
136 }
137
138 // now that we have all of the tables created, we are now free to add our sample data to populate the database
139
140 // First with Students....
141
142 int statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Students (firstName, lastName) VALUES (?, ?)", -1, &myStatement, NULL);
143
144 sqlite3_bind_text(myStatement, 1, "Travis", -1, SQLITE_STATIC);
145 sqlite3_bind_text(myStatement, 2, "Dillard", -1, SQLITE_STATIC);
146
147 if (statusOfPrep == SQLITE_OK)
148 {
149 int statusOfStep = sqlite3_step(myStatement);
150
151 if (statusOfStep == SQLITE_DONE)
152 {
153 //cout << "Successfully inserted into the database" << endl;
154 }
155 else
156 {
157 cout << "Problem inserting into the database" << endl;
158 }
159
160 sqlite3_finalize(myStatement);
161 }
162 else
163 {
164 cout << "Problem creating a prepared statement" << endl;
165 }
166
167 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Students (firstName, lastName) VALUES (?, ?)", -1, &myStatement, NULL);
168
169 sqlite3_bind_text(myStatement, 1, "Carson", -1, SQLITE_STATIC);
170 sqlite3_bind_text(myStatement, 2, "Bashford", -1, SQLITE_STATIC);
171
172 if (statusOfPrep == SQLITE_OK)
173 {
174 int statusOfStep = sqlite3_step(myStatement);
175
176 if (statusOfStep == SQLITE_DONE)
177 {
178 //cout << "Successfully inserted into the database" << endl;
179 }
180 else
181 {
182 cout << "Problem inserting into the database" << endl;
183 }
184
185 sqlite3_finalize(myStatement);
186 }
187 else
188 {
189 cout << "Problem creating a prepared statement" << endl;
190 }
191
192 // Now with advisers....
193
194 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Advisers (firstName, lastName) VALUES (?, ?)", -1, &myStatement, NULL);
195
196 sqlite3_bind_text(myStatement, 1, "Mark", -1, SQLITE_STATIC);
197 sqlite3_bind_text(myStatement, 2, "Mahoney", -1, SQLITE_STATIC);
198
199 if (statusOfPrep == SQLITE_OK)
200 {
201 int statusOfStep = sqlite3_step(myStatement);
202
203 if (statusOfStep == SQLITE_DONE)
204 {
205 //cout << "Successfully inserted into the database" << endl;
206 }
207 else
208 {
209 cout << "Problem inserting into the database" << endl;
210 }
211
212 sqlite3_finalize(myStatement);
213 }
214 else
215 {
216 cout << "Problem creating a prepared statement" << endl;
217 }
218
219 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Advisers (firstName, lastName) VALUES (?, ?)", -1, &myStatement, NULL);
220
221 sqlite3_bind_text(myStatement, 1, "Perry", -1, SQLITE_STATIC);
222 sqlite3_bind_text(myStatement, 2, "Kivolowitz", -1, SQLITE_STATIC);
223
224 if (statusOfPrep == SQLITE_OK)
225 {
226 int statusOfStep = sqlite3_step(myStatement);
227
228 if (statusOfStep == SQLITE_DONE)
229 {
230 //cout << "Successfully inserted into the database" << endl;
231 }
232 else
233 {
234 cout << "Problem inserting into the database" << endl;
235 }
236
237 sqlite3_finalize(myStatement);
238 }
239 else
240 {
241 cout << "Problem creating a prepared statement" << endl;
242 }
243
244 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Advisers (firstName, lastName) VALUES (?, ?)", -1, &myStatement, NULL);
245
246 sqlite3_bind_text(myStatement, 1, "Erlan", -1, SQLITE_STATIC);
247 sqlite3_bind_text(myStatement, 2, "Wheeler", -1, SQLITE_STATIC);
248
249 if (statusOfPrep == SQLITE_OK)
250 {
251 int statusOfStep = sqlite3_step(myStatement);
252
253 if (statusOfStep == SQLITE_DONE)
254 {
255 //cout << "Successfully inserted into the database" << endl;
256 }
257 else
258 {
259 cout << "Problem inserting into the database" << endl;
260 }
261
262 sqlite3_finalize(myStatement);
263 }
264 else
265 {
266 cout << "Problem creating a prepared statement" << endl;
267 }
268
269 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Advisers (firstName, lastName) VALUES (?, ?)", -1, &myStatement, NULL);
270
271 sqlite3_bind_text(myStatement, 1, "William", -1, SQLITE_STATIC);
272 sqlite3_bind_text(myStatement, 2, "Schroeder", -1, SQLITE_STATIC);
273
274 if (statusOfPrep == SQLITE_OK)
275 {
276 int statusOfStep = sqlite3_step(myStatement);
277
278 if (statusOfStep == SQLITE_DONE)
279 {
280 //cout << "Successfully inserted into the database" << endl;
281 }
282 else
283 {
284 cout << "Problem inserting into the database" << endl;
285 }
286
287 sqlite3_finalize(myStatement);
288 }
289 else
290 {
291 cout << "Problem creating a prepared statement" << endl;
292 }
293
294 // Now Courses....
295
296 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
297
298 sqlite3_bind_text(myStatement, 1, "CSC 1810", -1, SQLITE_STATIC);
299 sqlite3_bind_text(myStatement, 2, "Principles of Computer Science I", -1, SQLITE_STATIC);
300 sqlite3_bind_int(myStatement, 3, 4);
301 sqlite3_bind_text(myStatement, 4, "Yes", -1, SQLITE_STATIC);
302 sqlite3_bind_text(myStatement, 5, "N/A", -1, SQLITE_STATIC);
303
304 if (statusOfPrep == SQLITE_OK)
305 {
306 int statusOfStep = sqlite3_step(myStatement);
307
308 if (statusOfStep == SQLITE_DONE)
309 {
310 //cout << "Successfully inserted into the database" << endl;
311 }
312 else
313 {
314 cout << "Problem inserting into the database" << endl;
315 }
316
317 sqlite3_finalize(myStatement);
318 }
319 else
320 {
321 cout << "Problem creating a prepared statement" << endl;
322 }
323
324 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
325
326 sqlite3_bind_text(myStatement, 1, "CSC 1820", -1, SQLITE_STATIC);
327 sqlite3_bind_text(myStatement, 2, "Principles of Computer Science II", -1, SQLITE_STATIC);
328 sqlite3_bind_int(myStatement, 3, 4);
329 sqlite3_bind_text(myStatement, 4, "Yes", -1, SQLITE_STATIC);
330 sqlite3_bind_text(myStatement, 5, "CSC 1810 - Principles of Computer Science I", -1, SQLITE_STATIC);
331
332 if (statusOfPrep == SQLITE_OK)
333 {
334 int statusOfStep = sqlite3_step(myStatement);
335
336 if (statusOfStep == SQLITE_DONE)
337 {
338 //cout << "Successfully inserted into the database" << endl;
339 }
340 else
341 {
342 cout << "Problem inserting into the database" << endl;
343 }
344
345 sqlite3_finalize(myStatement);
346 }
347 else
348 {
349 cout << "Problem creating a prepared statement" << endl;
350 }
351
352 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
353
354 sqlite3_bind_text(myStatement, 1, "CSC 2560", -1, SQLITE_STATIC);
355 sqlite3_bind_text(myStatement, 2, "Data Structures and Algorithms", -1, SQLITE_STATIC);
356 sqlite3_bind_int(myStatement, 3, 4);
357 sqlite3_bind_text(myStatement, 4, "Yes", -1, SQLITE_STATIC);
358 sqlite3_bind_text(myStatement, 5, "CSC 1820 - Principles of Computer Science II", -1, SQLITE_STATIC);
359
360 if (statusOfPrep == SQLITE_OK)
361 {
362 int statusOfStep = sqlite3_step(myStatement);
363
364 if (statusOfStep == SQLITE_DONE)
365 {
366 //cout << "Successfully inserted into the database" << endl;
367 }
368 else
369 {
370 cout << "Problem inserting into the database" << endl;
371 }
372
373 sqlite3_finalize(myStatement);
374 }
375 else
376 {
377 cout << "Problem creating a prepared statement" << endl;
378 }
379
380 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
381
382 sqlite3_bind_text(myStatement, 1, "CSC 3510", -1, SQLITE_STATIC);
383 sqlite3_bind_text(myStatement, 2, "Computer Organization", -1, SQLITE_STATIC);
384 sqlite3_bind_int(myStatement, 3, 4);
385 sqlite3_bind_text(myStatement, 4, "Yes", -1, SQLITE_STATIC);
386 sqlite3_bind_text(myStatement, 5, "CSC 1820 - Principles of Computer Science II", -1, SQLITE_STATIC);
387
388 if (statusOfPrep == SQLITE_OK)
389 {
390 int statusOfStep = sqlite3_step(myStatement);
391
392 if (statusOfStep == SQLITE_DONE)
393 {
394 //cout << "Successfully inserted into the database" << endl;
395 }
396 else
397 {
398 cout << "Problem inserting into the database" << endl;
399 }
400
401 sqlite3_finalize(myStatement);
402 }
403 else
404 {
405 cout << "Problem creating a prepared statement" << endl;
406 }
407
408 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
409
410 sqlite3_bind_text(myStatement, 1, "CSC 4350", -1, SQLITE_STATIC);
411 sqlite3_bind_text(myStatement, 2, "Software Design and Development", -1, SQLITE_STATIC);
412 sqlite3_bind_int(myStatement, 3, 4);
413 sqlite3_bind_text(myStatement, 4, "Yes", -1, SQLITE_STATIC);
414 sqlite3_bind_text(myStatement, 5, "CSC 1820 - Principles of Computer Science II", -1, SQLITE_STATIC);
415
416 if (statusOfPrep == SQLITE_OK)
417 {
418 int statusOfStep = sqlite3_step(myStatement);
419
420 if (statusOfStep == SQLITE_DONE)
421 {
422 //cout << "Successfully inserted into the database" << endl;
423 }
424 else
425 {
426 cout << "Problem inserting into the database" << endl;
427 }
428
429 sqlite3_finalize(myStatement);
430 }
431 else
432 {
433 cout << "Problem creating a prepared statement" << endl;
434 }
435
436 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
437
438 sqlite3_bind_text(myStatement, 1, "CSC 4730", -1, SQLITE_STATIC);
439 sqlite3_bind_text(myStatement, 2, "Operating Systems", -1, SQLITE_STATIC);
440 sqlite3_bind_int(myStatement, 3, 4);
441 sqlite3_bind_text(myStatement, 4, "Yes", -1, SQLITE_STATIC);
442 sqlite3_bind_text(myStatement, 5, "CSC 1820 - Principles of Computer Science II", -1, SQLITE_STATIC);
443
444 if (statusOfPrep == SQLITE_OK)
445 {
446 int statusOfStep = sqlite3_step(myStatement);
447
448 if (statusOfStep == SQLITE_DONE)
449 {
450 //cout << "Successfully inserted into the database" << endl;
451 }
452 else
453 {
454 cout << "Problem inserting into the database" << endl;
455 }
456
457 sqlite3_finalize(myStatement);
458 }
459 else
460 {
461 cout << "Problem creating a prepared statement" << endl;
462 }
463
464 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
465
466 sqlite3_bind_text(myStatement, 1, "MTH 1240", -1, SQLITE_STATIC);
467 sqlite3_bind_text(myStatement, 2, "Discrete Structures", -1, SQLITE_STATIC);
468 sqlite3_bind_int(myStatement, 3, 4);
469 sqlite3_bind_text(myStatement, 4, "Yes", -1, SQLITE_STATIC);
470 sqlite3_bind_text(myStatement, 5, "N/A", -1, SQLITE_STATIC);
471
472 if (statusOfPrep == SQLITE_OK)
473 {
474 int statusOfStep = sqlite3_step(myStatement);
475
476 if (statusOfStep == SQLITE_DONE)
477 {
478 //cout << "Successfully inserted into the database" << endl;
479 }
480 else
481 {
482 cout << "Problem inserting into the database" << endl;
483 }
484
485 sqlite3_finalize(myStatement);
486 }
487 else
488 {
489 cout << "Problem creating a prepared statement" << endl;
490 }
491
492 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
493
494 sqlite3_bind_text(myStatement, 1, "CSC 4000", -1, SQLITE_STATIC);
495 sqlite3_bind_text(myStatement, 2, "Senior Seminar", -1, SQLITE_STATIC);
496 sqlite3_bind_int(myStatement, 3, 4);
497 sqlite3_bind_text(myStatement, 4, "Yes", -1, SQLITE_STATIC);
498 sqlite3_bind_text(myStatement, 5, "Senior Standing", -1, SQLITE_STATIC);
499
500 if (statusOfPrep == SQLITE_OK)
501 {
502 int statusOfStep = sqlite3_step(myStatement);
503
504 if (statusOfStep == SQLITE_DONE)
505 {
506 //cout << "Successfully inserted into the database" << endl;
507 }
508 else
509 {
510 cout << "Problem inserting into the database" << endl;
511 }
512
513 sqlite3_finalize(myStatement);
514 }
515 else
516 {
517 cout << "Problem creating a prepared statement" << endl;
518 }
519
520 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
521
522 sqlite3_bind_text(myStatement, 1, "CSC 4990", -1, SQLITE_STATIC);
523 sqlite3_bind_text(myStatement, 2, "Data Structures and Algorithms", -1, SQLITE_STATIC);
524 sqlite3_bind_int(myStatement, 3, 4);
525 sqlite3_bind_text(myStatement, 4, "Yes", -1, SQLITE_STATIC);
526 sqlite3_bind_text(myStatement, 5, "CSC 4000 - Senior Seminar", -1, SQLITE_STATIC);
527
528 if (statusOfPrep == SQLITE_OK)
529 {
530 int statusOfStep = sqlite3_step(myStatement);
531
532 if (statusOfStep == SQLITE_DONE)
533 {
534 //cout << "Successfully inserted into the database" << endl;
535 }
536 else
537 {
538 cout << "Problem inserting into the database" << endl;
539 }
540
541 sqlite3_finalize(myStatement);
542 }
543 else
544 {
545 cout << "Problem creating a prepared statement" << endl;
546 }
547
548 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
549
550 sqlite3_bind_text(myStatement, 1, "CSC 2030", -1, SQLITE_STATIC);
551 sqlite3_bind_text(myStatement, 2, "Data Science I", -1, SQLITE_STATIC);
552 sqlite3_bind_int(myStatement, 3, 4);
553 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
554 sqlite3_bind_text(myStatement, 5, "Sophomore Standing", -1, SQLITE_STATIC);
555
556 if (statusOfPrep == SQLITE_OK)
557 {
558 int statusOfStep = sqlite3_step(myStatement);
559
560 if (statusOfStep == SQLITE_DONE)
561 {
562 //cout << "Successfully inserted into the database" << endl;
563 }
564 else
565 {
566 cout << "Problem inserting into the database" << endl;
567 }
568
569 sqlite3_finalize(myStatement);
570 }
571 else
572 {
573 cout << "Problem creating a prepared statement" << endl;
574 }
575
576 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
577
578 sqlite3_bind_text(myStatement, 1, "CSC 2810", -1, SQLITE_STATIC);
579 sqlite3_bind_text(myStatement, 2, "Database Design and Management", -1, SQLITE_STATIC);
580 sqlite3_bind_int(myStatement, 3, 4);
581 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
582 sqlite3_bind_text(myStatement, 5, "CSC 1820 - Principles of Computer Science II", -1, SQLITE_STATIC);
583
584 if (statusOfPrep == SQLITE_OK)
585 {
586 int statusOfStep = sqlite3_step(myStatement);
587
588 if (statusOfStep == SQLITE_DONE)
589 {
590 //cout << "Successfully inserted into the database" << endl;
591 }
592 else
593 {
594 cout << "Problem inserting into the database" << endl;
595 }
596
597 sqlite3_finalize(myStatement);
598 }
599 else
600 {
601 cout << "Problem creating a prepared statement" << endl;
602 }
603
604 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
605
606 sqlite3_bind_text(myStatement, 1, "CSC 2910", -1, SQLITE_STATIC);
607 sqlite3_bind_text(myStatement, 2, "Object-Oriented Programming", -1, SQLITE_STATIC);
608 sqlite3_bind_int(myStatement, 3, 4);
609 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
610 sqlite3_bind_text(myStatement, 5, "CSC 1820 - Principles of Computer Science II", -1, SQLITE_STATIC);
611
612 if (statusOfPrep == SQLITE_OK)
613 {
614 int statusOfStep = sqlite3_step(myStatement);
615
616 if (statusOfStep == SQLITE_DONE)
617 {
618 //cout << "Successfully inserted into the database" << endl;
619 }
620 else
621 {
622 cout << "Problem inserting into the database" << endl;
623 }
624
625 sqlite3_finalize(myStatement);
626 }
627 else
628 {
629 cout << "Problem creating a prepared statement" << endl;
630 }
631
632 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
633
634 sqlite3_bind_text(myStatement, 1, "CSC 3210", -1, SQLITE_STATIC);
635 sqlite3_bind_text(myStatement, 2, "Computing Paradigms", -1, SQLITE_STATIC);
636 sqlite3_bind_int(myStatement, 3, 4);
637 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
638 sqlite3_bind_text(myStatement, 5, "CSC 2560 - Data Structures and Algorithms", -1, SQLITE_STATIC);
639
640 if (statusOfPrep == SQLITE_OK)
641 {
642 int statusOfStep = sqlite3_step(myStatement);
643
644 if (statusOfStep == SQLITE_DONE)
645 {
646 //cout << "Successfully inserted into the database" << endl;
647 }
648 else
649 {
650 cout << "Problem inserting into the database" << endl;
651 }
652
653 sqlite3_finalize(myStatement);
654 }
655 else
656 {
657 cout << "Problem creating a prepared statement" << endl;
658 }
659
660 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
661
662 sqlite3_bind_text(myStatement, 1, "CSC 3530", -1, SQLITE_STATIC);
663 sqlite3_bind_text(myStatement, 2, "Artificial Intelligence and Cognitive Modeling", -1, SQLITE_STATIC);
664 sqlite3_bind_int(myStatement, 3, 4);
665 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
666 sqlite3_bind_text(myStatement, 5, "CSC 2560 - Data Structures and Algorithms", -1, SQLITE_STATIC);
667
668 if (statusOfPrep == SQLITE_OK)
669 {
670 int statusOfStep = sqlite3_step(myStatement);
671
672 if (statusOfStep == SQLITE_DONE)
673 {
674 //cout << "Successfully inserted into the database" << endl;
675 }
676 else
677 {
678 cout << "Problem inserting into the database" << endl;
679 }
680
681 sqlite3_finalize(myStatement);
682 }
683 else
684 {
685 cout << "Problem creating a prepared statement" << endl;
686 }
687
688 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
689
690 sqlite3_bind_text(myStatement, 1, "CSC 3600", -1, SQLITE_STATIC);
691 sqlite3_bind_text(myStatement, 2, "Data Communications", -1, SQLITE_STATIC);
692 sqlite3_bind_int(myStatement, 3, 4);
693 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
694 sqlite3_bind_text(myStatement, 5, "CSC 2560 - Data Structures and Algorithms", -1, SQLITE_STATIC);
695
696 if (statusOfPrep == SQLITE_OK)
697 {
698 int statusOfStep = sqlite3_step(myStatement);
699
700 if (statusOfStep == SQLITE_DONE)
701 {
702 //cout << "Successfully inserted into the database" << endl;
703 }
704 else
705 {
706 cout << "Problem inserting into the database" << endl;
707 }
708
709 sqlite3_finalize(myStatement);
710 }
711 else
712 {
713 cout << "Problem creating a prepared statement" << endl;
714 }
715
716 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
717
718 sqlite3_bind_text(myStatement, 1, "CSC 3750", -1, SQLITE_STATIC);
719 sqlite3_bind_text(myStatement, 2, "Algorithms", -1, SQLITE_STATIC);
720 sqlite3_bind_int(myStatement, 3, 4);
721 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
722 sqlite3_bind_text(myStatement, 5, "CSC 1820 - Principles of Computer Science II", -1, SQLITE_STATIC);
723
724 if (statusOfPrep == SQLITE_OK)
725 {
726 int statusOfStep = sqlite3_step(myStatement);
727
728 if (statusOfStep == SQLITE_DONE)
729 {
730 //cout << "Successfully inserted into the database" << endl;
731 }
732 else
733 {
734 cout << "Problem inserting into the database" << endl;
735 }
736
737 sqlite3_finalize(myStatement);
738 }
739 else
740 {
741 cout << "Problem creating a prepared statement" << endl;
742 }
743
744 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
745
746 sqlite3_bind_text(myStatement, 1, "CSC 3770", -1, SQLITE_STATIC);
747 sqlite3_bind_text(myStatement, 2, "Introduction to Computer Graphics", -1, SQLITE_STATIC);
748 sqlite3_bind_int(myStatement, 3, 4);
749 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
750 sqlite3_bind_text(myStatement, 5, "CSC 2560 - Data Structures and Algorithms", -1, SQLITE_STATIC);
751
752 if (statusOfPrep == SQLITE_OK)
753 {
754 int statusOfStep = sqlite3_step(myStatement);
755
756 if (statusOfStep == SQLITE_DONE)
757 {
758 //cout << "Successfully inserted into the database" << endl;
759 }
760 else
761 {
762 cout << "Problem inserting into the database" << endl;
763 }
764
765 sqlite3_finalize(myStatement);
766 }
767 else
768 {
769 cout << "Problem creating a prepared statement" << endl;
770 }
771
772 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
773
774 sqlite3_bind_text(myStatement, 1, "CSC 3810", -1, SQLITE_STATIC);
775 sqlite3_bind_text(myStatement, 2, "Foundations of Computer Science", -1, SQLITE_STATIC);
776 sqlite3_bind_int(myStatement, 3, 4);
777 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
778 sqlite3_bind_text(myStatement, 5, "CSC 3750 - Algorithms", -1, SQLITE_STATIC);
779
780 if (statusOfPrep == SQLITE_OK)
781 {
782 int statusOfStep = sqlite3_step(myStatement);
783
784 if (statusOfStep == SQLITE_DONE)
785 {
786 //cout << "Successfully inserted into the database" << endl;
787 }
788 else
789 {
790 cout << "Problem inserting into the database" << endl;
791 }
792
793 sqlite3_finalize(myStatement);
794 }
795 else
796 {
797 cout << "Problem creating a prepared statement" << endl;
798 }
799
800 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
801
802 sqlite3_bind_text(myStatement, 1, "CSC 4500", -1, SQLITE_STATIC);
803 sqlite3_bind_text(myStatement, 2, "Independent Study", -1, SQLITE_STATIC);
804 sqlite3_bind_int(myStatement, 3, 4);
805 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
806 sqlite3_bind_text(myStatement, 5, "CSC 2560 - Data Structures and Algorithms", -1, SQLITE_STATIC);
807
808 if (statusOfPrep == SQLITE_OK)
809 {
810 int statusOfStep = sqlite3_step(myStatement);
811
812 if (statusOfStep == SQLITE_DONE)
813 {
814 //cout << "Successfully inserted into the database" << endl;
815 }
816 else
817 {
818 cout << "Problem inserting into the database" << endl;
819 }
820
821 sqlite3_finalize(myStatement);
822 }
823 else
824 {
825 cout << "Problem creating a prepared statement" << endl;
826 }
827
828 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
829
830 sqlite3_bind_text(myStatement, 1, "CSC 4650", -1, SQLITE_STATIC);
831 sqlite3_bind_text(myStatement, 2, "Computer Architecture", -1, SQLITE_STATIC);
832 sqlite3_bind_int(myStatement, 3, 4);
833 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
834 sqlite3_bind_text(myStatement, 5, "CSC 3510 - Computer Organization", -1, SQLITE_STATIC);
835
836 if (statusOfPrep == SQLITE_OK)
837 {
838 int statusOfStep = sqlite3_step(myStatement);
839
840 if (statusOfStep == SQLITE_DONE)
841 {
842 //cout << "Successfully inserted into the database" << endl;
843 }
844 else
845 {
846 cout << "Problem inserting into the database" << endl;
847 }
848
849 sqlite3_finalize(myStatement);
850 }
851 else
852 {
853 cout << "Problem creating a prepared statement" << endl;
854 }
855
856 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO Courses (courseNumber, courseName, numberOfCredits, isRequired, coursePrerequisites) VALUES (?, ?, ?, ?, ?)", -1, &myStatement, NULL);
857
858 sqlite3_bind_text(myStatement, 1, "CSC 4900", -1, SQLITE_STATIC);
859 sqlite3_bind_text(myStatement, 2, "Research in Computer Science", -1, SQLITE_STATIC);
860 sqlite3_bind_int(myStatement, 3, 4);
861 sqlite3_bind_text(myStatement, 4, "No", -1, SQLITE_STATIC);
862 sqlite3_bind_text(myStatement, 5, "CSC 1820 - Principles of Computer Science II", -1, SQLITE_STATIC);
863
864 if (statusOfPrep == SQLITE_OK)
865 {
866 int statusOfStep = sqlite3_step(myStatement);
867
868 if (statusOfStep == SQLITE_DONE)
869 {
870 //cout << "Successfully inserted into the database" << endl;
871 }
872 else
873 {
874 cout << "Problem inserting into the database" << endl;
875 }
876
877 sqlite3_finalize(myStatement);
878 }
879 else
880 {
881 cout << "Problem creating a prepared statement" << endl;
882 }
883
884 // Now the Classes that Students have taken...
885
886 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO StudentTakesCourses (studentID, courseID, semesterAndYear) VALUES (?, ?, ?)", -1, &myStatement, NULL);
887
888 sqlite3_bind_int(myStatement, 1, 1);
889 sqlite3_bind_int(myStatement, 2, 1);
890 sqlite3_bind_text(myStatement, 3, "Spring 2016", -1, SQLITE_STATIC);
891
892 if (statusOfPrep == SQLITE_OK)
893 {
894 int statusOfStep = sqlite3_step(myStatement);
895
896 if (statusOfStep == SQLITE_DONE)
897 {
898 //cout << "Successfully inserted into the database" << endl;
899 }
900 else
901 {
902 cout << "Problem inserting into the database" << endl;
903 }
904
905 sqlite3_finalize(myStatement);
906 }
907 else
908 {
909 cout << "Problem creating a prepared statement" << endl;
910 }
911
912 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO StudentTakesCourses (studentID, courseID, semesterAndYear) VALUES (?, ?, ?)", -1, &myStatement, NULL);
913
914 sqlite3_bind_int(myStatement, 1, 1);
915 sqlite3_bind_int(myStatement, 2, 2);
916 sqlite3_bind_text(myStatement, 3, "Fall 2016", -1, SQLITE_STATIC);
917
918 if (statusOfPrep == SQLITE_OK)
919 {
920 int statusOfStep = sqlite3_step(myStatement);
921
922 if (statusOfStep == SQLITE_DONE)
923 {
924 //cout << "Successfully inserted into the database" << endl;
925 }
926 else
927 {
928 cout << "Problem inserting into the database" << endl;
929 }
930
931 sqlite3_finalize(myStatement);
932 }
933 else
934 {
935 cout << "Problem creating a prepared statement" << endl;
936 }
937
938 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO StudentTakesCourses (studentID, courseID, semesterAndYear) VALUES (?, ?, ?)", -1, &myStatement, NULL);
939
940 sqlite3_bind_int(myStatement, 1, 1);
941 sqlite3_bind_int(myStatement, 2, 3);
942 sqlite3_bind_text(myStatement, 3, "Fall 2016", -1, SQLITE_STATIC);
943
944 if (statusOfPrep == SQLITE_OK)
945 {
946 int statusOfStep = sqlite3_step(myStatement);
947
948 if (statusOfStep == SQLITE_DONE)
949 {
950 //cout << "Successfully inserted into the database" << endl;
951 }
952 else
953 {
954 cout << "Problem inserting into the database" << endl;
955 }
956
957 sqlite3_finalize(myStatement);
958 }
959 else
960 {
961 cout << "Problem creating a prepared statement" << endl;
962 }
963
964 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO StudentTakesCourses (studentID, courseID, semesterAndYear) VALUES (?, ?, ?)", -1, &myStatement, NULL);
965
966 sqlite3_bind_int(myStatement, 1, 1);
967 sqlite3_bind_int(myStatement, 2, 5);
968 sqlite3_bind_text(myStatement, 3, "Spring 2017", -1, SQLITE_STATIC);
969
970 if (statusOfPrep == SQLITE_OK)
971 {
972 int statusOfStep = sqlite3_step(myStatement);
973
974 if (statusOfStep == SQLITE_DONE)
975 {
976 //cout << "Successfully inserted into the database" << endl;
977 }
978 else
979 {
980 cout << "Problem inserting into the database" << endl;
981 }
982
983 sqlite3_finalize(myStatement);
984 }
985 else
986 {
987 cout << "Problem creating a prepared statement" << endl;
988 }
989
990 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO StudentTakesCourses (studentID, courseID, semesterAndYear) VALUES (?, ?, ?)", -1, &myStatement, NULL);
991
992 sqlite3_bind_int(myStatement, 1, 1);
993 sqlite3_bind_int(myStatement, 2, 8);
994 sqlite3_bind_text(myStatement, 3, "J-Term 2018", -1, SQLITE_STATIC);
995
996 if (statusOfPrep == SQLITE_OK)
997 {
998 int statusOfStep = sqlite3_step(myStatement);
999
1000 if (statusOfStep == SQLITE_DONE)
1001 {
1002 //cout << "Successfully inserted into the database" << endl;
1003 }
1004 else
1005 {
1006 cout << "Problem inserting into the database" << endl;
1007 }
1008
1009 sqlite3_finalize(myStatement);
1010 }
1011 else
1012 {
1013 cout << "Problem creating a prepared statement" << endl;
1014 }
1015
1016 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO StudentTakesCourses (studentID, courseID, semesterAndYear) VALUES (?, ?, ?)", -1, &myStatement, NULL);
1017
1018 sqlite3_bind_int(myStatement, 1, 2);
1019 sqlite3_bind_int(myStatement, 2, 1);
1020 sqlite3_bind_text(myStatement, 3, "Fall 2015", -1, SQLITE_STATIC);
1021
1022 if (statusOfPrep == SQLITE_OK)
1023 {
1024 int statusOfStep = sqlite3_step(myStatement);
1025
1026 if (statusOfStep == SQLITE_DONE)
1027 {
1028 //cout << "Successfully inserted into the database" << endl;
1029 }
1030 else
1031 {
1032 cout << "Problem inserting into the database" << endl;
1033 }
1034
1035 sqlite3_finalize(myStatement);
1036 }
1037 else
1038 {
1039 cout << "Problem creating a prepared statement" << endl;
1040 }
1041
1042 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO StudentTakesCourses (studentID, courseID, semesterAndYear) VALUES (?, ?, ?)", -1, &myStatement, NULL);
1043
1044 sqlite3_bind_int(myStatement, 1, 2);
1045 sqlite3_bind_int(myStatement, 2, 2);
1046 sqlite3_bind_text(myStatement, 3, "Spring 2016", -1, SQLITE_STATIC);
1047
1048 if (statusOfPrep == SQLITE_OK)
1049 {
1050 int statusOfStep = sqlite3_step(myStatement);
1051
1052 if (statusOfStep == SQLITE_DONE)
1053 {
1054 //cout << "Successfully inserted into the database" << endl;
1055 }
1056 else
1057 {
1058 cout << "Problem inserting into the database" << endl;
1059 }
1060
1061 sqlite3_finalize(myStatement);
1062 }
1063 else
1064 {
1065 cout << "Problem creating a prepared statement" << endl;
1066 }
1067
1068 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO StudentTakesCourses (studentID, courseID, semesterAndYear) VALUES (?, ?, ?)", -1, &myStatement, NULL);
1069
1070 sqlite3_bind_int(myStatement, 1, 2);
1071 sqlite3_bind_int(myStatement, 2, 3);
1072 sqlite3_bind_text(myStatement, 3, "Fall 2016", -1, SQLITE_STATIC);
1073
1074 if (statusOfPrep == SQLITE_OK)
1075 {
1076 int statusOfStep = sqlite3_step(myStatement);
1077
1078 if (statusOfStep == SQLITE_DONE)
1079 {
1080 //cout << "Successfully inserted into the database" << endl;
1081 }
1082 else
1083 {
1084 cout << "Problem inserting into the database" << endl;
1085 }
1086
1087 sqlite3_finalize(myStatement);
1088 }
1089 else
1090 {
1091 cout << "Problem creating a prepared statement" << endl;
1092 }
1093
1094 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO StudentTakesCourses (studentID, courseID, semesterAndYear) VALUES (?, ?, ?)", -1, &myStatement, NULL);
1095
1096 sqlite3_bind_int(myStatement, 1, 2);
1097 sqlite3_bind_int(myStatement, 2, 6);
1098 sqlite3_bind_text(myStatement, 3, "J-Term 2017", -1, SQLITE_STATIC);
1099
1100 if (statusOfPrep == SQLITE_OK)
1101 {
1102 int statusOfStep = sqlite3_step(myStatement);
1103
1104 if (statusOfStep == SQLITE_DONE)
1105 {
1106 //cout << "Successfully inserted into the database" << endl;
1107 }
1108 else
1109 {
1110 cout << "Problem inserting into the database" << endl;
1111 }
1112
1113 sqlite3_finalize(myStatement);
1114 }
1115 else
1116 {
1117 cout << "Problem creating a prepared statement" << endl;
1118 }
1119
1120 statusOfPrep = sqlite3_prepare_v2(db, "INSERT INTO StudentTakesCourses (studentID, courseID, semesterAndYear) VALUES (?, ?, ?)", -1, &myStatement, NULL);
1121
1122 sqlite3_bind_int(myStatement, 1, 2);
1123 sqlite3_bind_int(myStatement, 2, 9);
1124 sqlite3_bind_text(myStatement, 3, "Spring 2017", -1, SQLITE_STATIC);
1125
1126 if (statusOfPrep == SQLITE_OK)
1127 {
1128 int statusOfStep = sqlite3_step(myStatement);
1129
1130 if (statusOfStep == SQLITE_DONE)
1131 {
1132 //cout << "Successfully inserted into the database" << endl;
1133 }
1134 else
1135 {
1136 cout << "Problem inserting into the database" << endl;
1137 }
1138
1139 sqlite3_finalize(myStatement);
1140 }
1141 else
1142 {
1143 cout << "Problem creating a prepared statement" << endl;
1144 }
1145}
1146
1147int main()
1148{
1149 sqlite3 * db;
1150 sqlite3_stmt* myStatement;
1151
1152 string path = "C:\\Users\\tdill\\Desktop\\Databases\\advising.sqlite";
1153 int statusOfOpen = sqlite3_open(path.c_str(), &db);
1154
1155 if (statusOfOpen == SQLITE_OK)
1156 {
1157 initializeDB(db);
1158 }
1159 else
1160 {
1161 cout << "Error opening database!" << endl;
1162 }
1163
1164 return 0;
1165}
1166
1167
1168// query to list all advisers
1169//
1170//cout << "Welcome to the advising app, to continue, please select an adviser!" << endl << endl;
1171//
1172//int statusOfPrep = sqlite3_prepare_v2(db, "SELECT Advisers.firstName, Advisers.lastName FROM Advisers", -1, &myStatement, NULL);
1173//
1174//if (statusOfPrep == SQLITE_OK)
1175//{
1176// int statusOfStep = sqlite3_step(myStatement);
1177// int counter = 1;
1178//
1179// while (statusOfStep == SQLITE_ROW)
1180// {
1181// char * firstName = (char *)sqlite3_column_text(myStatement, 0);
1182// char * lastName = (char *)sqlite3_column_text(myStatement, 1);
1183//
1184// cout << counter << ".) " << firstName << " " << lastName << endl;
1185//
1186// counter++;
1187// statusOfStep = sqlite3_step(myStatement);
1188// }
1189//
1190// sqlite3_finalize(myStatement);
1191//}
1192//else
1193//{
1194// cout << "Problem creating a prepared statement" << endl;
1195//}