0% found this document useful (0 votes)
13 views7 pages

32-ITE-01 Group 2 (SAO)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views7 pages

32-ITE-01 Group 2 (SAO)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Student Affairs Office (SAO)

1. Entities and Attributes

List of entities

 academic_records
 awards
 disciplinary_actions (Junction Table of students and violations)
 organizations
 programs
 students
 student_grades (Junction Table of academics records and programs)
 student_organizations (Junction Table of students and organizations)
 violations

Attributes for each entity with data types

 Academic records
o Academic records ID – id int(12)
o Student ID – student_id int(12)
o School year from - school_year_from int(12)
o School year to – school_year_to int(12)
o Semester – semester int(12)
o Course – course varchar(50)

 Awards
o Award ID – id int(12)
o Student ID – student_id int(12)
o Name – name varchar(50)
o Description – description varchar(255)
o Category – category varchar(50)
o Date awarded – date_awarded datetime
o Awarded by – awarded_by varchar(50)

 Disciplinary actions
o Discriplinary action ID – id int(12)
o Student ID – student_id int(12)
o Violation ID – violation_id int(12)
o Resolution – resolution varchar(255)
o Status – status int(1)
o Remark – remark varchar(255)
o Created at – created_at timestamp
o Updated at – updated_at timestamp

 Organizations
o Organization ID – id int(12)
o Name – name varchar(50)
o Activities – activities varchar(50)
o Created at – created_at timestamp
o Updated at – updated_at timestamp

 Programs
o Program Code – code int(12)
o Description – description varchar(255)
o Unit – unit int(12)
 Students
o Students id – id int(12)
o Name – name varchar(50)
o Gender – gender enum('female', 'male', 'other')
o Phone number – phone_number bigint(20)
o Birthdate – birthdate varchar(50)
o Registered at – registered_at timestamp
o Update at – updated_at timestamp
o Is enrolled – is_enrolled tinyint(1)

 Student grades
o Student grade ID – id int(12)
o Program code – program_code int(12)
o Academic record ID – academic_record_id int(12)
o Final grade – final_grade int(12)

 Student organizations
o Student organization ID – id int(12)
o Student ID – student_id int(12)
o Org ID – org_id int(12)

 Violations
o Violation ID – id int(12)
o Name – name varchar(50)
o Description – description varchar(255)

Primary keys and unique constraints

 Primary Keys
o id – Academic records Entity
o id – Awards Entity
o id – Disciplinary actions Entity
o id – Organizations Entity
o code – Programs Entity
o id – Students Entity
o id – Student grades Entity
o id – Student organizations Entity
o id – Violations Entity

2. Relationships

Description of relationships between entities

 Academic records and Programs


- One academic record can have many programs, and one program can
include in many Academic records. Thus, it is a many-to-many relationship,
resulting in a junction table called Student grades.

 Students and Academic records


- One student can have many academic records, and one academic record
refers to only one student.
 Students and Award
- One student can have many awards, and one award record refers to only
one student.
 Students and Organizations
- One student can join many organizations, and one organization can have
many students. Thus, it is a many-to-many relationship, resulting in a
junction table called Student organizations.

 Students and Violations


- One student can have many violations, and one violation can be taken by
many students. Thus, it is a many-to-many relationship, resulting in a
junction table called Disciplinary actions.

Types of relationships (one-to-one, one-to-many, many-to-many)

 Academic records and Programs – many-to-many


 Students and Academic records – one-to-many
 Students and Awards – one-to-many
 Students and Organization – many-to-many
 Students and Violations– many-to-many

Foreign keys used to establish relationships

 Academic Record ID and Program ID foreign keys of the Student Grades entity are
connected to the primary keys of the Academic Records entity and Programs entity
to establish the relationship between the Academic Records entity and Programs
entity.
 Student ID, a foreign key of the Academic Records entity, is connected to the
primary key of the Students entity to establish the relationship between the
Students entity and Academic Records entity.
 Student ID, a foreign key of the Awards entity, is connected to the primary key of
the Students entity to establish the relationship between the Students entity and
Awards entity.
 Student ID and Organization ID foreign keys of the Student Organizations entity
are connected to the primary keys of the Students entity and Organizations entity
to establish the relationship between the Students entity and Organizations entity.
 Student ID and Violations ID foreign keys of the Disciplinary Actions entity are
connected to the primary keys of the Students entity and Violations entity to
establish the relationship between the Students entity and Violations entity.
3. ERD Overview

Visual representation of the ERD

Explanation of symbols and notation used

 Table represent the entities.


 Inside the table are the attributes of the entities.
 Key symbols are primary key attributes.
 Lines shows which entities are connected to one another.
 Lines connected from a primary key to another table are foreign key
attributes.
 Smoll dot means one in the relationship
 Big dot means one or many in the relationship

4. SQL Schema

SQL script for creating the database schema

 Create the Database


o SAO database
CREATE DATABASE sao;

 Use the Database


o SAO database
USE sao;

 Create the Table


o Academic records
CREATE TABLE `sao`.`academic_records` (
`id` INT(12) NOT NULL AUTO_INCREMENT ,
`student_id` INT(12) NOT NULL ,
`school_year_from` INT(12) NOT NULL ,
`school_year_to` INT(12) NOT NULL ,
`semester` INT(12) NOT NULL ,
`course` VARCHAR(50) NOT NULL ,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
o Awards
CREATE TABLE `sao`.`awards` (
`id` INT(12) NOT NULL AUTO_INCREMENT ,
`student_id` INT(12) NOT NULL ,
`name` VARCHAR(50) NOT NULL ,
`description` VARCHAR(255) NOT NULL ,
`category` VARCHAR(50) NOT NULL ,
`date_awarded` DATETIME NOT NULL DEFAULT
CURRENT_TIMESTAMP ,
`awarded_by` VARCHAR(50) NOT NULL ,
PRIMARY KEY (`id`))
ENGINE = InnoDB;

o Disciplinary actions
CREATE TABLE `sao`.`disciplinary_actions` (
`id` INT(12) NOT NULL AUTO_INCREMENT ,
`student_id` INT(12) NOT NULL ,
`violation_id` INT(12) NOT NULL ,
`resolution` VARCHAR(255) NOT NULL ,
`status` INT(1) NOT NULL ,
`remark` VARCHAR(255) NOT NULL ,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
,
`updated_at` TIMESTAMP NULL ,
PRIMARY KEY (`id`))
ENGINE = InnoDB;

o Organizations
CREATE TABLE `sao`.`organizations` (
`id` INT(12) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(50) NOT NULL ,
`activities` VARCHAR(50) NOT NULL ,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
,
`updated_at` TIMESTAMP NULL ,
PRIMARY KEY (`id`))
ENGINE = InnoDB;

o Programs
CREATE TABLE `sao`.`programs` (
`code` INT(12) NOT NULL AUTO_INCREMENT ,
`description` VARCHAR(255) NOT NULL ,
`unit` INT(12) NOT NULL ,
PRIMARY KEY (`code`))
ENGINE = InnoDB;
o Students
CREATE TABLE `sao`.`students` (
`id` INT(12) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(50) NOT NULL ,
`gender` ENUM("male", "female", "others") NOT NULL ,
`phone_number` BIGINT(20) NOT NULL ,
`birthdate` VARCHAR(50) NOT NULL ,
`registered_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMEST
AMP ,
`update_at` TIMESTAMP NULL ,
`is_enrolled` TINYINT(1) NOT NULL ,
PRIMARY KEY (`id`))
ENGINE = InnoDB;

o Student grades
CREATE TABLE `sao`.`student_grades` (
`id` INT(12) NOT NULL AUTO_INCREMENT ,
`program_code` INT(12) NOT NULL ,
`academic_record_id` INT(12) NOT NULL ,
`final_grade` INT(12) NOT NULL ,
PRIMARY KEY (`id`))
ENGINE = InnoDB;

o Student organizations
CREATE TABLE `sao`.`student_organizations` (
`id` INT(12) NOT NULL AUTO_INCREMENT ,
`student_id` INT(12) NOT NULL ,
`org_id` INT(12) NOT NULL ,
PRIMARY KEY (`id`))
ENGINE = InnoDB;

o Violations
CREATE TABLE `sao`.`violations` (
`id` INT(12) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(50) NOT NULL ,
`description` VARCHAR(255) NOT NULL ,
PRIMARY KEY (`id`))
ENGINE = InnoDB;

 Foreign Key Creation


o Student ID from Academic records entity
ALTER TABLE `academic_records`
ADD FOREIGN KEY (`student_id`) REFERENCES
`students`(`id`)
ON DELETE RESTRICT ON UPDATE RESTRICT;

o Student ID from Awards entity


ALTER TABLE `awards`
ADD FOREIGN KEY (`student_id`) REFERENCES
`students`(`id`)
ON DELETE RESTRICT ON UPDATE RESTRICT;
o Student ID from Disciplinary actions entity
ALTER TABLE `disciplinary_actions`
ADD FOREIGN KEY (`student_id`) REFERENCES
`students`(`id`)
ON DELETE RESTRICT ON UPDATE RESTRICT;

o Violation ID from Disciplinary actions entity


ALTER TABLE `disciplinary_actions`
ADD FOREIGN KEY (`violation_id`) REFERENCES
`violations`(`id`)
ON DELETE RESTRICT ON UPDATE RESTRICT;

o Program code ID from Student grades entity


ALTER TABLE `student_grades`
ADD FOREIGN KEY (`program_code`) REFERENCES
`programs`(`code`)
ON DELETE RESTRICT ON UPDATE RESTRICT;

o Academic record ID from Student grades entity


ALTER TABLE `student_grades`
ADD FOREIGN KEY (`academic_record_id`) REFERENCES
`academic_records`(`id`)
ON DELETE RESTRICT ON UPDATE RESTRICT;

o Student ID from Student organizations Entity


ALTER TABLE `student_organizations`
ADD FOREIGN KEY (`student_id`) REFERENCES
`students`(`id`)
ON DELETE RESTRICT ON UPDATE RESTRICT;

o Org ID from Student organizations Entity


ALTER TABLE `student_organizations`
ADD FOREIGN KEY (`org_id`) REFERENCES
`organizations`(`id`)
ON DELETE RESTRICT ON UPDATE RESTRICT;

 Index Creation
o Last Name from Organizations Entity
ALTER TABLE `organizations` ADD INDEX(`name`);

o Name from Students Entity


ALTER TABLE `students` ADD INDEX(`name`);

You might also like