+ All Categories
Home > Documents > CS501+DLD_EPW_WCC-TermProject_(1)

CS501+DLD_EPW_WCC-TermProject_(1)

Date post: 03-Apr-2018
Category:
Upload: evan-washington
View: 214 times
Download: 0 times
Share this document with a friend

of 24

Transcript
  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    1/24

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    2/24

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    3/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 2 of 23

    Entity-Relationship Diagram

    Relationships: Faculty members teach classes

    o One faculty member may teach zero or more classeso Each class is taught by only one faculty member

    Each Course may have zero or one Course as a prerequisite

    o One prerequisite is associated with one Course Each Course becomes a specific class with a section number

    o One Course may have many Class offeringso One Class belongs to one Course

    Students enroll in classes (ClassEnrollment)o One Student has zero or more entries in classEnrollmento Each entry in classEnrollment is associated with one Studento One Class has zero or more entries in ClassEnrollmento Each entry in ClassEnrollment is associated with one Class

    Each Class has a grading policyo One Class has one gradingPolicy

    o

    One GradingPolicy is associated with one Class Students in ClassEnrollment turn in Assignments

    o Each Student enrolled in a Class has one or more assignmentso One Assignment is turned in by one Student

    Each Assignment is associated with a GradingPolicyo Each GradingPolicy has many associated Assignmentso One Assignment is associated with one GradingPolicy

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    4/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 3 of 23

    Data DictionaryFaculty

    Relation schema

    Faculty(facultyNo, fName, lName, address, city, state, zipcode, phone)

    Primary Key

    facultyNo

    Alternate Key

    Foreign Key

    Attributes

    Name Description Data Type DomainCharacteristics

    Required Defaultvalue

    facultyNo Uniquelyidentifiesa faculty

    NUMERIC(10,0) Yes

    fName Facultyfirst name

    VARCHAR(25) Yes

    lName Faculty

    last name

    VARCHAR(25) Yes

    Address Facultyaddress

    VARCHAR(30) No

    City Facultycity

    VARCHAR(25) No

    State Facultystate

    VARCHAR(2) No

    Zipcode Faculty zip NUMERIC(5,0) NophoneNumber Faculty

    phoneVARCHAR(13) (XXX)-XXX-XXXX No

    Enterprise constraints

    None

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    5/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 4 of 23

    Students

    Relation schema

    Students(studentNo, fName, lName)

    Primary Key

    studentNo

    Alternate Key

    Foreign Key

    Attributes

    Name Description Data Type DomainCharacteristics

    Required Defaultvalue

    studentNo Uniquelyidentifiesa student

    NUMERIC(10,0) Yes

    fName Studentfirst name

    VARCHAR(25) Yes

    lName Studentlast name

    VARCHAR(25) Yes

    Enterprise constraints

    None

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    6/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 5 of 23

    Courses

    Relation schema

    Courses(CourseNo, cost, description, prereq)

    Primary Key

    courseNo

    Alternate Key

    Foreign Key

    Prereq REFERENCES Courses(courseNo)

    Attributes

    Name Description Data Type DomainCharacteristics

    Required Defaultvalue

    courseNo Course Numberof course

    VARCHAR(10) Yes

    Cost Cost ofcourse

    Decimal(10,2)

    No

    Description Desc ofcourse

    VARCHAR(50) Yes

    prereq Prereqs forcourse

    VARCHAR(10) No

    Enterprise constraints

    None

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    7/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 6 of 23

    Classes

    Relation schema

    Classes(courseNo, sectionNo, facultyNo, roomNo, hours)

    Primary Key

    courseNo, sectionNo

    Alternate Key

    Foreign Key

    courseNo REFERENCES Courses(courseNo)

    facultyNo REFERENCES Faculty(facultyNo)

    Attributes

    Name Description Data Type DomainCharacteristics

    Required Defaultvalue

    courseNo Course Numberof course

    VARCHAR(5) Yes

    sectionNo Sectionnumber ofcourse

    NUMERIC(3,0) Yes

    roomNo Room numberof course

    VARCHAR(5) Yes

    facultyNo Uniquelyidentifies afaculty

    NUMERIC(10,0) Yes

    Hours Hours ofcourse

    NUMERIC(1,0) Yes

    Enterprise constraints

    None

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    8/24

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    9/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 8 of 23

    GradingPolicy

    Relation schema

    GradingPolicy(courseNo, sectionNo, activity, weight, droplowest)

    Primary Key

    CourseNo, sectionNo

    Alternate Key

    Foreign Key

    courseNo, sectionNo REFERENCES Classes(courseNo, sectionNo)

    Attributes

    Name Description Data Type DomainCharacteristic

    Required Defaultvalue

    courseNo Course Number ofcourse

    VARCHAR(5) Yes

    sectionNo Section numberof course

    NUMERIC(3,0) Yes

    Activity Activityclassification

    VARCHAR(10) Yes

    Weight Percentageweight

    NUMERIC(2,2) Yes

    droplowest Drop lowest ornot

    NUMERIC(1,0) No

    Enterprise constraints

    None

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    10/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 9 of 23

    Assignment

    Relation schema

    Assignment(CourseNo, sectionNo, studentNo, assignmentType, assignmentNo, grade)

    Primary Key

    courseNo, sectionNo, studentNo, assignmentType, assignmentNo

    Alternate Key

    Foreign Key

    courseNo, sectionNo, studentNo REFERENCES ClassEnrollment(courseNo, sectionNo,studentNo)

    courseNo, sectionNo, assignmentType REFERENCES GradingPolicy(courseNo, sectionNo,activity)

    Attribute

    Name Description Data Type DomainCharacteristics

    Required

    Defaultvalue

    courseNo CourseNumber of

    course

    VARCHAR(5) Yes

    sectionNo Sectionnumber ofcourse

    NUMERIC(3,0) Yes

    studentNo Student IDnumber

    NUMERIC(10,0)

    Yes

    assignmentType Assignmentcategory

    VARCHAR(10) Yes

    assignmentNo Number ofassignmentforspecifiedtype

    Grade Grade ofassignment

    NUMERIC(10,2)

    Yes

    Enterprise constraints

    None

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    11/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 10 of 23

    DDL Source Code

    Faculty:CREATE TABLE Faculty( facultyNo numeric(10,0) NOT NULL, fName varchar2(25) NOT NULL,lName varchar2(25) NOT NULL,address varchar2(30),city varchar2(25),state varchar2(2),zipCode numeric(5,0),phone varchar2(13),CONSTRAINT faculty_pk PRIMARY KEY (facultyNo)

    );

    Students:CREATE TABLE Students(

    studentNo numeric(10,0) NOT NULL,fName varchar2(25) NOT NULL,lName varchar2(25) NOT NULL,CONSTRAINT students_pk PRIMARY KEY (studentNo)

    );

    Courses:CREATE TABLE Courses(

    CourseNo varchar2(5) NOT NULL,cost numeric(10,2),description varchar2(40) NOT NULL,prereq varchar2(5),CONSTRAINT Courses_pk PRIMARY KEY (CourseNo),CONSTRAINT fk_Courses FOREIGN KEY (prereq)

    REFERENCES Courses(CourseNo));

    Classes:CREATE TABLE Classes(

    courseNo varchar2(5) NOT NULL,sectionNo numeric(3,0) NOT NULL,facultyNo numeric(10,0) NOT NULL,roomNo varchar2(10) NOT NULL,hours numeric(1,0) NOT NULL,CONSTRAINT classes_pk PRIMARY KEY (CourseNo, sectionNo),CONSTRAINT classes_fk1 FOREIGN KEY (CourseNo)

    REFERENCES Courses(CourseNo),CONSTRAINT classes_fk2 FOREIGN KEY (facultyNo)

    REFERENCES Faculty(facultyNo));

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    12/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 11 of 23

    ClassEnrollment:CREATE TABLE ClassEnrollment(

    studentNo numeric(10,0) NOT NULL,CourseNo varchar2(5) NOT NULL,sectionNo numeric(3,0) NOT NULL,CONSTRAINT enrollment_pk PRIMARY KEY (studentNo,CourseNo,sectionNo),CONSTRAINT enrollment_fk1 FOREIGN KEY (studentNo)

    REFERENCES Students(studentNo),CONSTRAINT enrollment_fk2 FOREIGN KEY (CourseNo, sectionNo)

    REFERENCES Classes(CourseNo, sectionNo));

    GradingPolicy:CREATE TABLE GradingPolicy(

    CourseNo varchar2(5) NOT NULL,sectionNo numeric(3,0) NOT NULL,activity varchar2(10) NOT NULL,weight numeric(2,2) NOT NULL,dropLowest numeric(1,0),CONSTRAINT grading_pk PRIMARY KEY (CourseNo, sectionNo, activity),CONSTRAINT grading_fk FOREIGN KEY (CourseNo, sectionNo)

    REFERENCES Classes(CourseNo, sectionNo));

    Assignment:CREATE TABLE Assignment(

    CourseNo varchar2(5) NOT NULL,sectionNo numeric(3,0) NOT NULL,studentNo numeric(10,0) NOT NULL,assignmentType varchar2(10) NOT NULL,assignmentNo numeric(2,0) NOT NULL,grade numeric(10,2) NOT NULL,CONSTRAINT assignment_pk PRIMARY KEY (CourseNo, sectionNo, studentNo,

    assignmentType, assignmentNo),CONSTRAINT assignment_fk1 FOREIGN KEY (studentNo, CourseNo, sectionNo)

    REFERENCES ClassEnrollment(studentNo, CourseNo, sectionNo),CONSTRAINT assignment_fk2 FOREIGN KEY (CourseNo, sectionNo,

    assignmentType)REFERENCES GradingPolicy(courseNo, sectionNo, activity)

    );

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    13/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 12 of 23

    Temporary Objects

    VIEW Get Grades calculates final scores for all students in all sections of all courses.

    Source Code for View GetGrades

    CREATE OR REPLACE VIEW GetGrades ASSELECT COURSENO,SECTIONNO,STUDENTNO, TO_CHAR(SUM(SCORE), 00.00) as scoreFROM(

    SELECT courseno,sectionno,studentno , assignmenttype,CaseWhen droplowest = 1 then (sum(Score)- min(Score))/(count(*)-1)Else sum(score)/count(*)End as score

    From(Select aa.courseno, aa.sectionno, aa.studentno, aa.assignmenttype, aa.assignmentno,

    aa.score,gg.droplowestFrom(

    Select courseno,sectionno,studentno,assignmenttype,assignmentno, sum(weight *grade) as score

    From(Select a.courseno,a. sectionno, a.studentno,a.

    assignmenttype,a.assignmentno,g.weight,a. gradeFrom assignment aJoinGradingpolicy gOna.sectionno = g.sectionno and a.courseno = g.courseno

    and a.assignmenttype = g.activity)group by courseno,sectionno,studentno,assignmenttype,assignmentno) aa

    join gradingpolicy ggonaa.sectionno = gg.sectionno and aa.courseno = gg.courseno

    and aa.assignmenttype = gg.activityorder by studentno)

    group by courseno,sectionno,studentno , assignmenttype,droplowestorder by studentno)

    GROUP BY COURSENO,SECTIONNO,STUDENTNOORDER BY COURSENO;

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    14/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 13 of 23

    Surrogate Key DefinitionsThe following surrogate keys were used in this logical design:

    studentNoo A unique integer value assigned to students, beginning with 1.o studentNo identifies students.o It is incremented based on alphabetical order of last names.o This value is used to relate students to the courses they are taking and the assignments they turn

    in for those courses. facultyNo

    o A unique integer value assigned to faculty members, beginning with 1.o facultyNo identifies faculty members.

    o

    It is incremented based on alphabetical order of last names.o This value is used to relate faculty members with the courses they teach

    assignmentTypeo Identifies the type of assignment (i.e. PA, HM, QZ, Midterm, Final)o This value is used to relate the Assignment and GradingPolicy tables through a foreign key

    relationship. assignmentNo

    o Identifies the number of the assignment for a given class.o For example, if CS20 Section 1 has two assignments of assignmentType QZ then the

    assignmentNo for these assignments would be 1 and 2.

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    15/24

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    16/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 15 of 23

    Source CodeCalcGradeReport:

    CREATE OR REPLACE PROCEDURE CalcGradeReport(cNo IN VARCHAR2, sNo IN VARCHAR2, p_cursor

    OUT SYS_REFCURSOR)ASBEGINOPEN p_cursor FOR

    SELECT s.lName, s.fName, g.courseNo, g.sectionNo, g.scoreFROM GetGrades gJOIN Students sON g.studentNo = s.studentNoWHERE g.courseNo = cNo AND g.sectionNo = sNo;

    END CalcGradeReport;.RUN;

    CalcTranscript:CREATE OR REPLACE PROCEDURE CalcTranscript(stufName IN VARCHAR2, stulName IN VARCHAR2, p_cursor

    OUT SYS_REFCURSOR)

    ASBEGINOPEN p_cursor FOR

    SELECT s.lName, s.fName, g.courseNo, g.sectionNo, g.scoreFROM GetGrades gJOIN Students sON g.studentNo = s.studentNoWHERE s.fName = stufName AND s.lName = stulName;

    END CalcTranscript;.RUN;

    CourseEnrollment:CREATE OR REPLACE PROCEDURE CourseEnrollment(cNo IN VARCHAR2, p_cursor OUT SYS_REFCURSOR)ASBEGINOPEN p_cursor FOR

    SELECT courseNo, stuCountFROM(

    SELECT courseNo, COUNT(studentNo) AS stuCountFROM ClassEnrollmentGROUP BY courseNo

    )WHERE courseNo = cNo;

    END CourseEnrollment;.RUN;

    CourseInfo:CREATE OR REPLACE PROCEDURE CourseInfo(cNo IN VARCHAR2, p_cursor OUT SYS_REFCURSOR)ASBEGINOPEN p_cursor FOR

    SELECT c1.courseNo, c2.description, c1.stuCountFROM(

    SELECT courseNo, COUNT(studentNo) AS stuCountFROM ClassEnrollmentGROUP BY courseNo

    ) c1JOIN(

    SELECT courseNo, descriptionFROM Courses

    ) c2ON c1.courseNo = c2.courseNoWHERE c1.courseNo = cNo;

    END CourseInfo;.RUN;

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    17/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 16 of 23

    DML Query Source Code Set pagesize 1000

    Set linesize 1000

    1.) List detail of all different courses (neither class nor section) for this institute.

    SELECT *FROM COURSES;

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    18/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 17 of 23

    2.) How many active students stored in current database application?

    SELECT COUNT(studentNo)FROM(

    SELECT DISTINCT studentNoFROM ClassEnrollment

    );

    3.) How many different instructors? List their names and classes taught respectively. Order results byinstructor last name.

    SELECT COUNT(*) AS InstructorCountFROM Faculty;

    SELECT F.lname, F.fname, c.CourseNo, c.SectionNoFROM Faculty FLEFT OUTER JOIN Classes CON f.facultyNo=C.facultyNoORDER BY lname ASC;

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    19/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 18 of 23

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    20/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 19 of 23

    4.) How many students enrolled in a given course (For example, CS20, Intro to Computers)?

    VAR rc REFCURSOREXEC CourseEnrollment(CS20,:rc);Print rc

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    21/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 20 of 23

    5.) Generate grade report for any given class/section (For example, CS25, Section 4) Order results by studentlast name.

    VAR rc RefcursorEXEC CalcGradeReport('CS25', '4',:rc);Print rc

    6.) Generate transcript for any given student with first name and last name only. (For example, studentYvonne Williams) Order results by ascending order of course number.

    VAR rc REFCURSOREXECUTE CalcTranscript('Yvonne','Williams',:rc);Print rc

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    22/24

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    23/24

  • 7/28/2019 CS501+DLD_EPW_WCC-TermProject_(1)

    24/24

    CS501 Jax Profession Center Term Project January 26, 2013Dylan Dempsey Evan Washington Weicong Chen

    Page 23 of 23

    Change LogThe following changes have been made to the original logical design:

    Faculty Tableo Attributes address, city, state, zipcode, and phone are no longer required

    Studentso No changes

    Classo Class has been split into two separate tables

    Courses Consists of attributes courseNo, cost, description, and prereq Added prereq foreign key constraint that references courseNo to prevent

    inserting prerequisites for nonexistent classes Values for cost and prereq can now be NULL

    Classes Consists of attributes courseNo, sectionNo, facultyNo, room, and hours Added foreign key constraint courseNo, referencing Courses table Added foreign key constraint facultyNo referencing Faculty table

    CourseRecordso This table is now called classEnrollmento Primary constraint key has been added for courseNo, sectionNo, and studentNo to prevent

    students from registering for the same class multiple times GradingPolicy

    o Attributes participation, homework, quiz, midterm, and final have been replaced with a singleattribute, activity

    o Primary key constraint has been updated to include courseNo, sectionNo, and activity Assignment

    o Attribute assignmentID has been changed to assignmentNoo Old foreign key has been droppedo Added foreign key constraint courseNo, sectionNo, studentNo referencing ClassEnrollment tableo Added foreign key constraint courseNo, sectionNo, assignmentType referencing grading policy


Recommended