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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education