Question: 1 a . Create a unique index for inventory table on partno and name it as part _ inv _ index. Query: create UNIQUE INDEX
a Create a unique index for inventory table on partno and name it as partinvindex.
Query: create UNIQUE INDEX partinvindex ON inventory partno;
Output: INDEX PARTINVINDEX created.
b Create an index custbalanceindx to support sorting customers by postalcode, balance desc.
Query: CREATE INDEX custbalanceindx ON customer postalcode ASC, balance DESC;
Output: Index CUSTBALANCEINDX created.
a Permit joshi to update customer table.
Query: GRANT UPDATE ON customer TO joshi;
Output: Grant succeeded.
b Permit everyone to select all on your inventory table.
Query: GRANT SELECT ON inventory TO PUBLIC;
Output: Grant succeeded.
a Add a character type column named customertype with character positions to customer table.
Query: ALTER TABLE customer ADD customertype CHAR;
Output: Table CUSTOMER altered.
b Now change the width of customertype to characters in customer table.
Query: ALTER TABLE customer MODIFY customertype CHAR;
Output: Table CUSTOMER altered.
c Rename Price in Item table to ListPrice.
Query: ALTER TABLE Item RENAME COLUMN Price TO ListPrice;
Output: Table ITEM altered.
a Modify Enroll table refer to Tiny College to add a new column gradepoints. For the Follwing questions, refer to the ERD of Tiny College placed in Module Tiny College ERD.pdf
Before doing the query I created the tables for Tiny College ERD: Create table ProfessorProfNum int Primary key,DeptCode VARCHARProfSpeciality VARCHARProfRank int,ProfLname VARCHARProfFname VARCHARProfIntial VARCHARProfEmail VARCHAR;
Create table SchoolSchoolCode int Primary key,SchoolName VARCHARProfNum int;
Create table DepartmentDeptCode int Primary key,DeptName VARCHARSchoolCode int,ProfNum int;
Create table CourseCrsCode int Primary key,DeptCode int,CrsTitle VARCHARCRSDescription VARCHARCRSCredit int;
Create table ClassClassCode int Primary key,ClassSection int,ClassTime VARCHARCrsCode int,ProfNum int,RoomCode int;
Create table StudentStuNum int Primary key,DeptCode int,StuLname VARCHARStuFname VARCHARStuIntial VARCHARStuEmail VARCHARProfNum int;
Create table EnrollClassCode int,StuNum int,EnrollDate date,EnrollGrade VARCHAR;
Create table RoomRoomCode int Primary key,RoomType VARCHARBldgCode int;
Create table BuildingBldgCode int Primary key,BldgName VARCHARBldgLocation VARCHAR;
Query: ALTER TABLE Enroll ADD gradepoints DECIMAL;
Output: Table ENROLL altered.
b Now use case statement to fill gradepoint value of if the grade is A for B for C for D and for F
Query: UPDATE Enroll
SET gradepoints CASE
WHEN enrollgrade A THEN
WHEN enrollgrade B THEN
WHEN enrollgrade C THEN
WHEN enrollgrade D THEN
WHEN enrollgrade F THEN
ELSE NULL Handle other cases as needed
END;
Output: rows updated.
Now compute Average GPA in each class. Display classcode, ClassGPA. Assume all courses are credit courses. A general formula for GPA would be sumgradepoints x HrssumHrs Here you can just take an average of gradepoints as the credit hours are same for all courses.
Query: SELECT classcode, AVGgradepoints AS ClassGPA
FROM Enroll
GROUP BY classcode;
Output: null
Create a view CourseGrades showing GPA of all the students in a class with ClassCode: Include StudentNumber, StudentName, GPA. Grant read ability to Joshi for this view.
Provide a select statement, via which, Joshi can see the names, and GPAs of students with GPA above where GPAs are arranged in a descending order.
Query Part : CREATE VIEW CourseGrades AS
SELECT
estunum AS StudentNumber,
sstufname AS FirstName,
sstulname AS LastName,
eclasscode AS ClassCode,
egradepoints AS GPA
FROM Enroll e
JOIN Student s ON estunum sstunum
WHERE eclasscode ;
GRANT SELECT ON CourseGrades TO joshi;
Output Part : View COURSEGRADES created.
Grant succeeded.
Query Part : SELECT firstname, lastname, GPA
FROM CourseGrades
WHERE GPA
ORDER BY GPA DESC;
Output Part : no data
Is this correct?
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
