Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create the schema from Part 2 - c in SQLite and populate it with data of at least 5 students, 4 courses, and 8 enrollments

Create the schema from Part 2-c in SQLite and populate it with data of at least 5 students, 4 courses, and 8 enrollments (at least
one of the students should not be enrolled in any courses and at least one course should have zero current enrollments).
Student(StudentID, Name, Address, GradYear)
Grade(CName, Studentip, CGrade)
Course(CName, Department, Credits)
You can submit code in this document or as a separate .py file. If you submit it separately, please clearly document which part
each answer matches. Please do not submit each part in a separate .py file.
a) Create a view that joins the three tables, including all of the records from student table (i.e., including the non-
enrolled students).
b) Write and execute python code that uses that view to export all data into a single .txt file (that is a "de-normalized"
1NF file with some redundancy present). This code should include NULLs due to the non-enrolled students.
Include a screenshot of the output .txt file (in addition to the python code)
c) Add a new row to the de-normalized .txt file (you can manually edit the .txt file from part b) that violates the
following functional dependency:
CName Credits
(you can do so by creating a new record that repeats the course name but does not repeat the number of credits
associated with this course name)
d) Write python code that will identify the values for which functional dependency was violated in your .txt file (hint:
when the functional dependency is valid, there is only one unique value of Credits for each CName). Your solution
should detect any violation of the CName Credits functional dependency, not just your example. Keep in mind
that functional dependency is violated only in the pre-joined .txt file, not in the SQLite database, so this solution
must read data from .txt file.
e) Suppose I have a new query: Qe : For every department, display the min, median, and max graduation years.
Use the view from Part 4-a to re-write query Qe(i.e., replace the tables in the query's FROM clause by the
view and rewrite the rest of the query accordingly to produce an answer).
Use your .txt file containing de-normalized data from part-b to answer Qe with python instead of SQL.
Note that this solution should not use SQLite or SQL language. Your solution should work for any input,
not just for specific department in your data.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions