Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Assignment 0 1 Example : University Database ImplementationBusiness Use Case:A university wants to develop a database system to manage its academic operations. The system

Lab Assignment 01 Example : University Database ImplementationBusiness Use Case:A university wants to develop a database system to manage its academic operations. The system should keep track of students, professors, courses, departments, enrollments, and course assignments. The database will be used to store and retrieve information efficiently and ensure data integrity.Tasks:Identify Tables and Attributes:Based on the use case, identify at least five tables required for the university database.Define appropriate attributes for each table.Identify candidate keys and primary keys for each table.Create Tables:Write SQL scripts to create the identified tables with the defined attributes, including constraints for candidate keys, primary keys, and foreign keys.Insert Data:Insert sample data into each table to represent realistic university scenarios.Create Database Diagram:Generate a database diagram that includes all the tables and their relationships.Run SELECT Queries:Execute SELECT queries to retrieve and display the data from each table.Documentation:Include screenshots of the database diagram and the results of your SELECT queries in your submission.Step-by-Step Instructions:Step 1: Identify Tables and AttributesTables and Attributes:DepartmentsDepartmentID (INT, Primary Key)DepartmentCode (VARCHAR(10), Candidate Key)DepartmentName (VARCHAR(100))ProfessorsProfessorID (INT, Primary Key)SSN (CHAR(11), Candidate Key)Email (VARCHAR(255), Candidate Key)FirstName (VARCHAR(50))LastName (VARCHAR(50))HireDate (DATE)DepartmentID (INT, Foreign Key)StudentsStudentID (INT, Primary Key)SSN (CHAR(11), Candidate Key)Email (VARCHAR(255), Candidate Key)FirstName (VARCHAR(50))LastName (VARCHAR(50))DateOfBirth (DATE)CoursesCourseID (INT, Primary Key)CourseCode (VARCHAR(10), Candidate Key)CourseName (VARCHAR(100))Credits (INT)DepartmentID (INT, Foreign Key)EnrollmentsEnrollmentID (INT, Primary Key)StudentID (INT, Foreign Key)CourseID (INT, Foreign Key)EnrollmentDate (DATE)Grade (CHAR(2))UNIQUE (StudentID, CourseID)(Composite Candidate Key)CourseAssignmentsAssignmentID (INT, Primary Key)CourseID (INT, Foreign Key)ProfessorID (INT, Foreign Key)AssignmentDate (DATE)UNIQUE (CourseID, ProfessorID)(Composite Candidate Key)Step 2: Create Tables-- Creating Departments TableCREATE TABLE Departments ( DepartmentID INT NOT NULL, -- Candidate Key DepartmentCode VARCHAR(10) NOT NULL UNIQUE, -- Candidate Key DepartmentName VARCHAR(100) NOT NULL, PRIMARY KEY (DepartmentID)-- Primary Key);-- Creating Professors TableCREATE TABLE Professors ( ProfessorID INT NOT NULL, -- Candidate Key SSN CHAR(11) NOT NULL UNIQUE, -- Candidate Key Email VARCHAR(255) NOT NULL UNIQUE, -- Candidate Key FirstName VARCHAR(50), LastName VARCHAR(50), HireDate DATE, DepartmentID INT, PRIMARY KEY (ProfessorID),-- Primary Key FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID));-- Creating Students TableCREATE TABLE Students ( StudentID INT NOT NULL, -- Candidate Key SSN CHAR(11) NOT NULL UNIQUE, -- Candidate Key Email VARCHAR(255) NOT NULL UNIQUE, -- Candidate Key FirstName VARCHAR(50), LastName VARCHAR(50), DateOfBirth DATE, PRIMARY KEY (StudentID)-- Primary Key);-- Creating Courses TableCREATE TABLE Courses ( CourseID INT NOT NULL, -- Candidate Key CourseCode VARCHAR(10) NOT NULL UNIQUE, -- Candidate Key CourseName VARCHAR(100) NOT NULL, Credits INT, DepartmentID INT, PRIMARY KEY (CourseID),-- Primary Key FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID));-- Creating Enrollments TableCREATE TABLE Enrollments ( EnrollmentID INT NOT NULL, -- Candidate Key StudentID INT NOT NULL, CourseID INT NOT NULL, EnrollmentDate DATE, Grade CHAR(2), PRIMARY KEY (EnrollmentID),-- Primary Key UNIQUE (StudentID, CourseID),-- Candidate Key (Composite) FOREIGN KEY (StudentID) REFERENCES Students(StudentID), FOREIGN KEY (CourseID) REFERENCES Courses(CourseID));-- Creating CourseAssignments TableCREATE TABLE CourseAssignments ( AssignmentID INT NOT NULL, -- Candidate Key CourseID INT NOT NULL, ProfessorID INT NOT NULL, AssignmentDate DATE, PRIMARY KEY (AssignmentID),-- Primary Key UNIQUE (CourseID, ProfessorID),-- Candidate Key (Composite) FOREIGN KEY (CourseID) REFERENCES Courses(CourseID), FOREIGN KEY (ProfessorID) REFERENCES Professors(ProfessorID));Step 3: Insert DataSample Data:-- Inserting data into DepartmentsINSERT INTO Departments (DepartmentID, DepartmentCode, DepartmentName)VALUES (1,'CS', 'Computer Science'),(2, 'MATH', 'Mathematics'),(3,'PHYS', 'Physics');-- Inserting data into ProfessorsINSERT INTO Professors (ProfessorID, SSN, Email, FirstName, LastName, HireDate, DepartmentID)VALUES (1,'123-45-6789', 'jdoe@university.edu', 'John', 'Doe', '2005-08-15',1),(2,'987-65-4321', 'asmith@university.edu', 'Alice', 'Smith', '2010-09-01',2);-- Inserting data into StudentsINSERT INTO Students (StudentID, SSN, Email, FirstName, LastName, DateOfBirth)VALUES (1,'111-22-3333', 'bwilson@student.edu', 'Bob', 'Wilson', '1998-05-21'),(2,'444-55-6666', 'mjones@student.edu', 'Mary', 'Jones', '1999-07-15');-- Inserting data into CoursesINSERT INTO Courses (CourseID, CourseCode, CourseName, Credits, DepartmentID)VALUES (1,'CS101', 'Introduction to Computer Science', 4,1),(2, 'MATH101', 'Calculus I',3,2);-- Inserting data into EnrollmentsINSERT INTO Enrollments (EnrollmentID, StudentID, CourseID, EnrollmentDate, Grade)VALUES (1,1,1,'2023-01-15','A'),(2,2,2,'2023-01-15','B');-- Inserting data into CourseAssignmentsINSERT INTO CourseAssignments (AssignmentID, CourseID, ProfessorID, AssignmentDate)VALUES (1,1,1,'2023-01-01'),(2,2,2,'2023-01-01');Step 4: Create Database DiagramGenerate a database diagram that shows all the tables and their relationships. Ensure that the diagram clearly illustrates primary keys, foreign keys, and the relationships between the tables.Step 5: Run SELECT QueriesQueries to Verify Data:-- Select data from DepartmentsSELECT * FROM Departments;-- Select data from ProfessorsSELECT * FROM Professors;-- Select data from StudentsSELECT * FROM Students;-- Select data from CoursesSELECT * FROM Courses;-- Select data from EnrollmentsSELECT * FROM Enrollments;-- Select data from CourseAssignmentsSELECT * FROM CourseAssignments;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions