reate table queries CREATE TABLE Students(    StudentID INT NOT NULL PRIMARY KEY,    LastName VARCHAR(25) NOt NULL,    FirstName VARCHAR(25) NOT NULL,    EnrollmentDate DateTime2(0) NOt NULL,    GraduationDate Date NULL ) CREATE TABLE Courses(    CourseID INT NOT NULL PRIMARY KEY,    CourseNumber INT NULL,    CourseDescription VARCHAR(50) NOT NULL,    CourseUnits INT NOT NULL,    DepartMentID INT NOT NULL,    InstructorID INT NOT NULL ) CREATE TABLE StudentCourses(    StudentID INT NOT NULL,    CourseID INT NOT NULL,    PRIMARY KEY(StudentID, CourseID),    FOREIGN KEY (StudentID) REFERENCES Students(StudentID),    FOREIGN KEY (CourseID) REFERENCES Courses(CourseID) ) CREATE TABLE Tuition(    PartTimeCost SMALLMONEY NOT NULL,    FullTimeCost SMALLMONEY NOT NULL,    PerUnitCost SMALLMONEY NOT NULL ) arrow_forward Step 3 CREATE FUNCTION fnStudentUnits (    @studentID INT ) RETURNS INT AS BEGIN    -- Declare the return variable here    DECLARE @totalUnits INT    SET @totalUnits = 0    SELECT @totalUnits = SUM(CourseUnits)    FROM StudentCourses sc    INNER JOIN Students s ON s.StudentID = sc.StudentID    INNER JOIN Courses c ON c.CourseID = sc.CourseID    -- Return the result of the function    RETURN @totalUnits END GO   1. Using the Code above please create three tests: 1) test for a student who has courses

Oracle 12c: SQL
3rd Edition
ISBN:9781305251038
Author:Joan Casteel
Publisher:Joan Casteel
Chapter6: Additional Database Objects
Section: Chapter Questions
Problem 6HOA: A new table has been requested to support tracking automated emails sent to customers. Create the...
icon
Related questions
icon
Concept explainers
Question

Create table queries

CREATE TABLE Students(
   StudentID INT NOT NULL PRIMARY KEY,
   LastName VARCHAR(25) NOt NULL,
   FirstName VARCHAR(25) NOT NULL,
   EnrollmentDate DateTime2(0) NOt NULL,
   GraduationDate Date NULL
)

CREATE TABLE Courses(
   CourseID INT NOT NULL PRIMARY KEY,
   CourseNumber INT NULL,
   CourseDescription VARCHAR(50) NOT NULL,
   CourseUnits INT NOT NULL,
   DepartMentID INT NOT NULL,
   InstructorID INT NOT NULL
)

CREATE TABLE StudentCourses(
   StudentID INT NOT NULL,
   CourseID INT NOT NULL,
   PRIMARY KEY(StudentID, CourseID),
   FOREIGN KEY (StudentID) REFERENCES Students(StudentID),
   FOREIGN KEY (CourseID) REFERENCES Courses(CourseID)
)

CREATE TABLE Tuition(
   PartTimeCost SMALLMONEY NOT NULL,
   FullTimeCost SMALLMONEY NOT NULL,
   PerUnitCost SMALLMONEY NOT NULL
)

arrow_forward
Step 3

CREATE FUNCTION fnStudentUnits
(
   @studentID INT
)
RETURNS INT
AS
BEGIN
   -- Declare the return variable here
   DECLARE @totalUnits INT
   SET @totalUnits = 0

   SELECT @totalUnits = SUM(CourseUnits)
   FROM StudentCourses sc
   INNER JOIN Students s ON s.StudentID = sc.StudentID
   INNER JOIN Courses c ON c.CourseID = sc.CourseID

   -- Return the result of the function
   RETURN @totalUnits
END
GO

 

1. Using the Code above please create three tests:

1) test for a student who has courses

2) test for student who does not have courses

3) a non-existing student ID. For each test, display the value of the student ID that was passed to the function and the result returned by the function. Also, run a supportive SELECT query or queries that prove the test results are correct.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Query Syntax
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
A Guide to SQL
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr