Question: Set up your MySQL database on your system or with Docker. Set up your folder with the proper file structure and naming convention. Inside your
Set up your MySQL database on your system or with Docker.
Set up your folder with the proper file structure and naming convention.
Inside your users.sql file, create three users for your database. The first will be named adminuser with a password of admin the next will be readonly with a password of read and the last will be modifyuser with a password of modify Set this up so that the user can be used on any ip address that requests access to the database with the correct password.
Inside your permissions.sql file, create three roles for your database. The first will be called adminrole and you will grant it access to the entire database with the option to grant privileges to other users. The next role will be readrole and it will be granted the privilege to read but not modify any database in the system. The last role will be the modifyrole and it will be granted privileges to modify any database on the system.
Grant the corresponding role to each user. adminrole adminuser, readrole readuser, and modifyrole modify user. Don't forget to set the default role for each user!!
Create a Database and Table
Inside your DDLsql file, create a database with the database name SCHOOL. Check to make sure that the script can be run regardless if there is a database with that name already or not.
Create a table in your database. Here's your schema: Studentid: integer autoincrement Primary Key, firstname: varchar with up to character, lastname: varchar with up to characters, emailaddress: varchar with up to characters, dateofbirth: Date, studentgrade: Integer, teacherfirstname: varchar with up to characters, teacherlastname: varchar with up to characters, teacheremail: varchar with up to characters, roomnumber: Integer, subject: varchar with up to characters, classgrade: char with only character
Inside your DMLsql file, insert at least one tuple DML into your table
Decompose your Student table into three separate tables.
Your three tables should be named: Student, Teacher, and Classes. They should contain the same attributes that you had in your first monolithic table you created in week one. Each table will need a primary key. In the comments for each table. Explain to me the how you came to your primary key choice. List out the superkeys, the candidate keys, and why you chose the primary key that you did.
Create a foreign key reference to your tables to make sure that the tables can be joined.
Insert and Query:
Open your dmlsql file and insert some data into each table. Add at least tuples in each table. Make sure that each student has one teacher, a teacher has a classroom.
Open your query.sql file and write some queries on your database. At least queries Make sure that one of the queries has a join between two of the tables.
Write some more inserts to each table. Create the basic classes. Math, Science, English, and History. Assign a teacher to each of these and make sure that there are at least three students in each class. Make sure each student has a grade in each class they are in
Write a query that shows for each student the first and last name, class name, teacher name, and grade they are receiving for each class. Group this query by the student name and sort each class by the highest grade A to the lowest grade F
Create two functions and two procedures:
One function should be called addStudent and insert a student into the database. The other function should be called getTeacherId return the teacher id when searching for the teacher's first and last name.
The first procedure will be called getAllStudents and return all students in the students table. The second procedure will be called getTeacherStudents and return all the students that are taught by a specific teacher. You will need to take as arguments the name of the teacher. Make sure to use the function you created in the first part of this question to get the teacher id number inside of this procedure. You will need to use some variables and joins inside of your procedure to make this work!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
