Advanced Database Coursework
Advanced Database Coursework
1. Identifying Entities
Entities:
o Members
o Membership Types
o Payments
o Instructors
o Machinery
o Workouts
2. Relationships:
o One Member has One Membership Type (One-to-One)
o One Member can have Many Payments (One-to-Many)
o One Workout can have Many Members (Many-to-Many) through a separate table
(Workout_Members)
o One Workout can have One Instructor (One-to-Many)
o One Workout can have Many Machinery (Many-to-Many) through a separate
table (Workout_Machinery)
pg. 1
KHALID MAHDI FARAH 22/1172/BSSE-J
3. Payments Table:
SQL
CREATE TABLE Payments (
PaymentID INT AUTO_INCREMENT PRIMARY KEY,
PaymentDate DATE NOT NULL,
Amount DECIMAL(10,2) NOT NULL,
MemberID INT NOT NULL,
pg. 2
KHALID MAHDI FARAH 22/1172/BSSE-J
4. Instructors Table:
SQL
CREATE TABLE Instructors (
InstructorID INT AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(255) NOT NULL,
Gender VARCHAR(10) NOT NULL,
PhoneContact VARCHAR(20) NOT NULL,
Address TEXT,
Email VARCHAR(255) NOT NULL,
DateJoined DATE NOT NULL,
Photo BLOB,
Availability VARCHAR(255)
);
5. Machinery Table:
SQL
CREATE TABLE Machinery (
MachineID INT AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(255) NOT NULL,
Model VARCHAR(255),
NumberOfEquipment INT,
Description TEXT,
Price DECIMAL(10,2) NOT NULL,
DatePurchased DATE NOT NULL,
Photo BLOB
);
6. Workouts Table:
pg. 3
KHALID MAHDI FARAH 22/1172/BSSE-J
SQL
CREATE TABLE Workouts (
WorkoutID INT AUTO_INCREMENT PRIMARY KEY,
WorkoutName VARCHAR(255) NOT NULL,
Description TEXT,
Date DATETIME NOT NULL,
InstructorID INT NOT NULL,
FOREIGN KEY (InstructorID) REFERENCES Instructors(InstructorID)
);
pg. 4
KHALID MAHDI FARAH 22/1172/BSSE-J
Payments Table:
pg. 5
KHALID MAHDI FARAH 22/1172/BSSE-J
Instructors Table:
5. Take a screenshot for every table showing each table and the records in that table
pg. 6
KHALID MAHDI FARAH 22/1172/BSSE-J
pg. 7
KHALID MAHDI FARAH 22/1172/BSSE-J
6.
A. All members of the gym:
SQL
SELECT *
FROM Members;
SELECT *
FROM Members
C. All members of the gym that are students over the age of 25 years:
SQL
SELECT *
FROM Members
D. All members registered for the "Combat" class and the instructor in charge:
SQL
FROM Members m
FROM Machinery m
pg. 8
KHALID MAHDI FARAH 22/1172/BSSE-J
F. The total amount of money paid by all current members of the gym:
SQL
FROM Payments p
SELECT *
FROM Instructors
pg. 9