MySQL
Assignment - List Tables and Columns - Student Management System
Objective:
You are required to address a set of Data Definition Language (DDL) tasks for a Student Management System. Each query focuses on distinct DDL tasks, including the creation of tables, application of constraints, and establishment of relationships between tables.
Requirements:
You will need to complete at least 20 different DDL tasks, covering table creation, primary keys, foreign keys, constraints, and indexes. Each task represents a key part of designing the structure of the Student Management System.
Question 1: Create the SEMESTER Table
Write a DDL SQL statement to create a SEMESTER table with the following requirements:
semester_idas a primary key with auto-increment functionality.semester_nameas a string of maximum length 255 characters, not null.start_dateas a date field, not null.end_dateas a date field, not null.enrollment_statusas string with CHECK constraint (open, close), not null.created_dateas a date field, default it to system date, not null.
Question 2: Create the STUDENT Table
Write a DDL SQL statement to create a STUDENT table with the following requirements:
student_idas a primary key with auto-increment functionality.first_nameas a string of maximum length 255 characters, not null.last_nameas a string of maximum length 255 characters, not null.date_of_birthas a date field, not null.emailas a unique string, not null.created_dateas a date field, default it to system date, not null.
Question 3: Create the COURSE Table with Constraints
Create a COURSE table with the following specifications:
course_idas a primary key with auto-increment functionality.course_nameas a string with a maximum length of 255 characters, not null.department_idas a foreign key, not null.creditsas an integer, not null.- Add a
CHECKconstraint to ensure that thecreditsare between 1 and 6. created_dateas a date field, default it to system date, not null.
Question 4: Create the ENROLLMENT Table
Define an ENROLLMENT table with the following details:
enrollment_idas a primary key with auto-increment functionality.enrollment_dateas a date field, with the default value being the current date.student_idas a foreign key referencing the STUDENT table, not null.course_idas a foreign key referencing the COURSE table, not null.semester_idas a foreign key referencing the SEMESTER table, not null.grade_idas a foreign key referencing the GRADE table.amount_paidas a decimal (10, 2), null.amount_dueas a decimal (10, 2), null.
Question 5: Create the TEACHER Table with a Foreign Key
Define a TEACHER table:
teacher_idas a primary key with auto-increment functionality.first_nameas a string of maximum length 255 characters, not null.last_nameas a string of maximum length 255 characters, not null.emailas a unique string, not null.hire_dateas a date field, not null.department_idas a foreign key, null.created_dateas a date field, default it to system date, not null.
Question 6: Define the TEACHER_COURSE Table
Write the SQL statement to create a many-to-many relationship between teachers and courses. This will require the TEACHER_COURSE table, which includes:
teacher_idas a foreign key referencing the TEACHER table, not null.course_idas a foreign key referencing the COURSE table, not null.- Set up a composite primary key using
teacher_idandcourse_id. created_dateas a date field, default it to system date, not null.
Question 7: Create the DEPARTMENT Table
Create a DEPARTMENT table:
department_idas a primary key with auto-increment functionality.department_nameas a string of maximum length 255 characters, not null.created_dateas a date field, default it to system date, not null.
Question 8: Define the CLASSROOM Table with Relationships
Write the SQL statement to create a CLASSROOM table that includes:
classroom_idas a primary key with auto-increment functionality.room_numberas a string of maximum length 50 characters, not null.capacityas an integer, not null.department_idas a foreign key referencing the DEPARTMENT table, not null.created_dateas a date field, default it to system date, not null.
Question 9: Define the CLASS_SCHEDULE Table with Relationships
Write the SQL statement to create a CLASS_SCHEDULE table that includes:
class_schedule_idas a primary key with auto-increment functionality.semester_idas a foreign key referencing the SEMESTER table, not null.course_idas a foreign key referencing the COURSE table, not null.teacher_idas a foreign key referencing the TEACHER table, not null.start_dateas a date field, not null.end_dateas a date field, not null.start_timeas a time field, not null.end_timeas a time field, not null.created_dateas a date field, default it to system date, not null.
Question 10: Create the EXAM Table
Define an EXAM table with the following specifications:
exam_idas a primary key with auto-increment functionality.exam_nameas a date field, not null.created_dateas a date field, default it to system date, not null.
Question 11: Create the EXAM_SCHEDULE Table
Define an EXAM_SCHEDULE table with the following specifications:
exam_schedule_idas a primary key with auto-increment functionality.exam_dateas a date field, not null.exam_idas a foreign key referencing the EXAM table, not null.semester_idas a foreign key referencing the SEMESTER table, not null.course_idas a foreign key referencing the COURSE table, not null.room_idas a foreign key referencing the ROOM table, not null.total_marksas an integer, not null.start_timeas time, not null.end_timeas time, not null.created_dateas a date field, default it to system date, not null.
Question 12: Create the GRADE Table
Write a DDL SQL statement to create a GRADE table with the following details:
grade_idas the primary key with auto-increment functionality.grade_letteras a string of length 1, not null.grade_descriptionas a string of maximum length 255 characters.start_percentas a decimal, not null.end_percentas a decimal, not null.- Add a
CHECKconstraint to ensure thegrade_letteris between 'A' and 'F'. created_dateas a date field, default it to system date, not null.
Question 13: Create the EXAM_RESULT Table
Define an EXAM_RESULT table with the following specifications:
exam_schedule_idas a foreign key referencing the EXAM_SCHEDULE table, not null.student_idas a foreign key referencing the STUDENT table, not null.grade_idas a foreign key referencing the GRADE table, not null.created_dateas a date field, default it to system date, not null.- create composite primary key.
Question 14: Create the EXAM_RESULT_MASTER Table
Define an EXAM_RESULT table with the following specifications:
exam_idas a foreign key referencing the EXAM table, not null.student_idas a foreign key referencing the STUDENT table, not null.grade_idas a foreign key referencing the GRADE table, not null.semester_idas a foreign key referencing the SEMESTER table, not null.created_dateas a date field, default it to system date, not null.- create composite primary key.
Question 15: Create the ATTENDANCE Table
Write a DDL SQL statement to create an ATTENDANCE table:
attendance_idas the primary key with auto-increment functionality.attendance_dateas a date field, not null.student_idas a foreign key referencing the STUDENT table, not null.course_idas a foreign key referencing the COURSE table, not null.absence_flagas a boolean, true or false, not null.created_dateas a date field, default it to system date, not null.
Question 16: Create the FEE_STRUCTURE Table with Constraints
Write a DDL SQL statement to create a FEE_STRUCTURE table:
fee_idas a primary key with auto-increment functionality.course_idas a foreign key referencing the COURSE table, not null.fee_amountas a decimal (10, 2), not null.- Add a
CHECKconstraint to ensure thefee_amountis greater than 0. created_dateas a date field, default it to system date, not null.
Question 17: Create the FEE_PAYMENT Table with Constraints
Write a DDL SQL statement to create a FEE_PAYMENT table:
payment_idas a primary key with auto-increment functionality.student_idas a foreign key referencing the STUDENT table, not null.amount_paidas a decimal (10, 2), not null.balance_amountas a decimal (10, 2), not null.payment_dateas a datetime, not null.- Add a
CHECKconstraint to ensure thefee_amountis greater than 0.
Question 18: Create the EMPLOYEE_LOGIN Table
Write a DDL SQL statement to create an EMPLOYEE_LOGIN table (one-to-one relationship with employee table):
employee_idas a foreign key referencing the EMPLOYEE table.login_idcan use alpha numeric login id or email as login id, not null.passwordmust encrypt the password before storing it in the database table, not null.active_flaguse numeric, 0 or 1, you can lock the customer login when required, not null.last_login_datetimeas a timestamp, last successfull login date for a given employee.
Question 19: Create the AUDIT_LOG Table
Define an AUDIT_LOG table to track changes in the student management system:
log_idas a primary key with auto-increment functionality.log_dateas a date field, not null.actionas a string to describe the action performed, not null.user_idas a foreign key referencing the TEACHER or STUDENT table.
Question 20: Add a Column to the TEACHER Table
Write a SQL statement to add a phone_number column of type VARCHAR(15) to the TEACHER table.
Question 21: Alter a Column in the STUDENT Table
Write a SQL statement to alter the email column in the STUDENT table, increasing its length to 255 characters.
Question 22: Drop an Index from the TEACHER Table
Write a SQL statement to drop the index on the phone_number column in the TEACHER table.
Question 23: Rename the FEE_PAYMENT Table
Write a SQL statement to rename the FEE_PAYMENT table to PAYMENT_TRANSACTION.
Question 24: Add Primary Key
Write a SQL statement to add primary key to the EMPLOYEE_LOGIN table.
Question 25: Add a Foreign Key column to the EXAM_SCHEDULE Table
Add a foreign key in the EXAM_SCHEDULE table to reference the CLASSROOM table.
Question 26: Drop a Column from the EXAM_SCHEDULE Table
Write a SQL statement to drop the class_id column from the EXAM_SCHEDULE table.
Question 27: Add Indexes to the STUDENT and COURSE Tables
Write SQL statements to:
- Add an index on the
last_namecolumn in the STUDENT table. - Add an index on the
course_namecolumn in the COURSE table.
Question 28: Add a CHECK Constraint on the ENROLLMENT Table
Write a SQL statement to add a CHECK constraint to the ENROLLMENT table ensuring that the grade is between 'A' and 'F', or NULL.
Question 29: Drop the EMPLOYEE_LOGIN Table
Write a SQL statement to drop the EMPLOYEE_LOGIN table.
Question 30: Add a UNIQUE Constraint on the EXAM Table
Write a SQL statement to add a UNIQUE constraint to the EXAM table ensuring that the exam_name is not repeated.
Question 31: Enforce UNIQUE constraints on all applicable tables.
Apply UNIQUE constraints to columns across the entire database wherever duplicate data is not permitted.
GOOD LUCK WITH YOUR ASSIGNMENT!!!
Don't forget to contact us if you need any further assistance with your assignments, and most importantly, for a manual review and approval of your work.
SAMPLE TABLE DESIGN

To gain complete access, login with gmail or outlook, no need of signup, click here


Comments Not Found