/*==============================================================*/
/* DBMS name:      MySQL 5.0                                    */
/* Created on:     29/12/2010 15:46:19                          */
/*==============================================================*/


drop table if exists academic_area;

drop table if exists access_log;

drop table if exists activity;

drop table if exists activity_applied_criterias;

drop table if exists activity_attachment;

drop table if exists activity_policy_violations;

drop table if exists activity_type;

drop table if exists allowed_pages_by_process;

drop table if exists article;

drop table if exists authority;

drop table if exists authority_charge;

drop table if exists bus;

drop table if exists bus_driver;

drop table if exists bus_shift_year;

drop table if exists bus_year_user;

drop table if exists cat_period;

drop table if exists cat_subject;

drop table if exists change_reason;

drop table if exists classroom;

drop table if exists class_group;

drop table if exists country;

drop table if exists course;

drop table if exists course_director;

drop table if exists credit_card;

drop table if exists currency;

drop table if exists current_deferred;

drop table if exists degree;

drop table if exists discipline;

drop table if exists employee;

drop table if exists employee_area;

drop table if exists financial_institution;

drop table if exists general_activity;

drop table if exists general_activity_attendees;

drop table if exists general_discipline_log;

drop table if exists grade_change_log;

drop table if exists grade_criteria;

drop table if exists grade_subject_score;

drop table if exists group_hour;

drop table if exists group_hour_level;

drop table if exists guardian;

drop table if exists guest;

drop table if exists hour;

drop table if exists hour_by_group;

drop table if exists incident;

drop table if exists income_stock;

drop table if exists invoice;

drop table if exists invoice_detail;

drop table if exists item_category;

drop table if exists language;

drop table if exists level;

drop table if exists level_section_year;

drop table if exists level_section_year_specialty;

drop table if exists maintenance_item;

drop table if exists master_degree;

drop table if exists medical_file;

drop table if exists message;

drop table if exists message_between_profiles;

drop table if exists message_thread;

drop table if exists message_thread_messages;

drop table if exists ministry_subject;

drop table if exists nationality;

drop table if exists optional_subject;

drop table if exists optional_subject_level;

drop table if exists optional_subject_period;

drop table if exists optional_subject_retest;

drop table if exists optional_subject_retest_student;

drop table if exists opt_activity;

drop table if exists opt_activity_applied_criterias;

drop table if exists opt_activity_attachment;

drop table if exists opt_grade_change_log;

drop table if exists opt_student_activity_attachment;

drop table if exists opt_student_criteria_grade;

drop table if exists opt_subject_period_activity_type;

drop table if exists opt_subject_year_activity_criteria_period;

drop table if exists opt_subject_year_grade_criteria;

drop table if exists payment_concept;

drop table if exists payment_detail;

drop table if exists payment_method;

drop table if exists period;

drop table if exists period_group_year;

drop table if exists pre_registration;

drop table if exists pre_registration_period;

drop table if exists process;

drop table if exists profile;

drop table if exists profile_process;

drop table if exists provider;

drop table if exists psychological_file;

drop table if exists qualifying_document;

drop table if exists qualitative_equivalence;

drop table if exists request_detail;

drop table if exists route;

drop table if exists school_setup;

drop table if exists school_year;

drop table if exists section;

drop table if exists section_by_year;

drop table if exists shift;

drop table if exists specialty;

drop table if exists state;

drop table if exists stock_request;

drop table if exists student;

drop table if exists student_activity_attachment;

drop table if exists student_by_course;

drop table if exists student_criteria_grade;

drop table if exists student_guardian;

drop table if exists student_optional_subject;

drop table if exists student_year;

drop table if exists student_year_debts;

drop table if exists student_year_document;

drop table if exists student_year_special_grade;

drop table if exists subject;

drop table if exists subject_course;

drop table if exists subject_course_period;

drop table if exists subject_course_retest;

drop table if exists subject_course_retest_student;

drop table if exists subject_ministry_equivalence;

drop table if exists subject_period_activity_type;

drop table if exists subject_year_activity_criteria_period;

drop table if exists subject_year_grade_criteria;

drop table if exists syllabus_files;

drop table if exists syllabus_files_change_log;

drop table if exists taxes;

drop table if exists teacher_degree;

drop table if exists teacher_hours_year;

drop table if exists teacher_master_degree;

drop table if exists teacher_specialty;

drop table if exists university;

drop table if exists user;

drop table if exists user_profile;

drop table if exists use_destination;

drop table if exists visits_medical_center;

drop table if exists year_concept_taxes;

drop table if exists year_grade_subject;

drop table if exists year_level_specialty_payment_concept;

drop table if exists year_qualifying_document;

drop table if exists year_resit_exam_ranges;

drop table if exists year_special_grade;

drop table if exists year_subject_classroom;

/*==============================================================*/
/* Table: academic_area                                         */
/*==============================================================*/
create table academic_area
(
   serial_aca           int not null auto_increment,
   name_aca             varchar(150) not null,
   description_aca      text not null,
   status_aca           enum('ACTIVE','INACTIVE') not null,
   primary key (serial_aca)
)
type = innodb;

/*==============================================================*/
/* Table: access_log                                            */
/*==============================================================*/
create table access_log
(
   serial_alg           int not null auto_increment,
   serial_usr           int,
   serial_prf           int,
   login_date_alg       timestamp not null,
   primary key (serial_alg)
)
type = innodb;

/*==============================================================*/
/* Table: activity                                              */
/*==============================================================*/
create table activity
(
   serial_act           int not null auto_increment,
   name_act             varchar(256) not null,
   description_act      text not null,
   send_date_act        timestamp not null,
   due_date_act         timestamp not null,
   status_act           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_act)
)
type = innodb;

/*==============================================================*/
/* Table: activity_applied_criterias                            */
/*==============================================================*/
create table activity_applied_criterias
(
   serial_att           int not null,
   serial_prd           int not null,
   serial_sbc           int not null,
   serial_sbj           int not null,
   serial_gct           int not null,
   serial_act           int not null,
   weight_aac           decimal(5,2) not null,
   status_aac           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_att, serial_prd, serial_sbc, serial_gct, serial_act)
)
type = innodb;

/*==============================================================*/
/* Table: activity_attachment                                   */
/*==============================================================*/
create table activity_attachment
(
   serial_ath           int not null auto_increment,
   serial_act           int,
   name_ath             varchar(256) not null,
   filename_ath         varchar(256) not null,
   status_ath           enum('ACTIVE','INACTIVE','DELETED') not null default 'ACTIVE',
   primary key (serial_ath)
)
type = innodb;

/*==============================================================*/
/* Table: activity_policy_violations                            */
/*==============================================================*/
create table activity_policy_violations
(
   serial_opa           int,
   serial_act           int,
   serial_emp           int,
   start_date_apv       date not null,
   end_date_apv         date not null
)
type = innodb;

/*==============================================================*/
/* Table: activity_type                                         */
/*==============================================================*/
create table activity_type
(
   serial_att           int not null auto_increment,
   name_att             varchar(256) not null,
   description_att      text not null,
   status_att           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_att)
)
type = innodb;

/*==============================================================*/
/* Table: allowed_pages_by_process                              */
/*==============================================================*/
create table allowed_pages_by_process
(
   serial_prc           int,
   url_dsc              varchar(1024) not null
)
type = innodb;

/*==============================================================*/
/* Table: article                                               */
/*==============================================================*/
create table article
(
   serial_art           int not null auto_increment,
   code_art             varchar(10) not null,
   name_art             varchar(250) not null,
   stock_art            int not null,
   status_art           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_art)
)
type = innodb;

/*==============================================================*/
/* Table: authority                                             */
/*==============================================================*/
create table authority
(
   serial_aut           int not null auto_increment,
   serial_atc           int,
   id_aut               varchar(15) not null,
   degree_aut           varchar(50) not null,
   first_name_aut       varchar(100) not null,
   last_name_aut        varchar(100) not null,
   in_charge_aut        enum('YES','NO') not null,
   primary key (serial_aut)
)
type = innodb;

/*==============================================================*/
/* Table: authority_charge                                      */
/*==============================================================*/
create table authority_charge
(
   serial_atc           int not null auto_increment,
   name_atc             varchar(100) not null,
   description_atc      text,
   status_atc           enum('ACTIVE','INACTIVE') not null,
   primary key (serial_atc)
)
type = innodb;

/*==============================================================*/
/* Table: bus                                                   */
/*==============================================================*/
create table bus
(
   serial_bus           int not null auto_increment,
   code_bus             varchar(13) not null,
   plate_num_bus        varchar(12) not null,
   description_bus      text not null,
   capacity_bus         int not null,
   status_bus           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_bus)
)
type = innodb;

/*==============================================================*/
/* Table: bus_driver                                            */
/*==============================================================*/
create table bus_driver
(
   serial_bdr           int not null auto_increment,
   id_bdr               varchar(13) not null,
   first_name_bdr       varchar(512) not null,
   last_name_bdr        varchar(512) not null,
   mobile1_bdr          varchar(13),
   mobile2_bdr          varchar(13),
   phone1_bdr           varchar(13) not null,
   phone2_bdr           varchar(13),
   phone3_bdr           varchar(13),
   address_bdr          text not null,
   drive_license_bdr    varchar(20) not null,
   license_expire_date_bdr date not null,
   status_bdr           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_bdr)
)
type = innodb;

/*==============================================================*/
/* Table: bus_shift_year                                        */
/*==============================================================*/
create table bus_shift_year
(
   serial_bdr           int not null,
   serial_rot           int not null,
   serial_scy           int not null,
   serial_bus           int not null,
   serial_sft           int not null,
   bus_serial_bdr       int,
   status_bpy           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_rot, serial_scy, serial_bus, serial_sft)
)
type = innodb;

/*==============================================================*/
/* Table: bus_year_user                                         */
/*==============================================================*/
create table bus_year_user
(
   serial_usr           int,
   serial_rot           int,
   serial_scy           int,
   serial_bus           int,
   serial_sft           int,
   status_byu           enum('ACTIVE','INACTIVE') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: cat_period                                            */
/*==============================================================*/
create table cat_period
(
   serial_cpd           int not null auto_increment,
   name_cpd             varchar(100) not null,
   description_cpd      text,
   status_cpd           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_cpd)
)
type = innodb;

/*==============================================================*/
/* Table: cat_subject                                           */
/*==============================================================*/
create table cat_subject
(
   serial_csb           int not null auto_increment,
   cat_serial_csb       int,
   serial_aca           int,
   serial_lng           int,
   code_csb             varchar(20) not null,
   name_csb             varchar(255) not null,
   status_csb           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_csb)
)
type = innodb;

/*==============================================================*/
/* Table: change_reason                                         */
/*==============================================================*/
create table change_reason
(
   serial_chr           int not null auto_increment,
   name_chr             varchar(256) not null,
   type_chr             enum('DISCIPLINE','ACTIVITY','BOTH') not null default 'BOTH',
   status_chr           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_chr)
)
type = innodb;

/*==============================================================*/
/* Table: classroom                                             */
/*==============================================================*/
create table classroom
(
   serial_clr           int not null auto_increment,
   name_clr             varchar(80) not null,
   capacity_clr         int not null,
   description_clr      text not null,
   status_clr           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_clr)
)
type = innodb;

/*==============================================================*/
/* Table: class_group                                           */
/*==============================================================*/
create table class_group
(
   serial_clg           int not null auto_increment,
   name_clg             varchar(150) not null,
   description_clg      text,
   status_clg           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_clg)
)
type = innodb;

/*==============================================================*/
/* Table: country                                               */
/*==============================================================*/
create table country
(
   serial_cou           int not null auto_increment,
   name_cou             varchar(100),
   status_cou           enum('ACTIVE','INACTIVE') default 'ACTIVE',
   primary key (serial_cou)
)
type = innodb;

/*==============================================================*/
/* Table: course                                                */
/*==============================================================*/
create table course
(
   serial_crs           int not null auto_increment,
   serial_clg           int,
   serial_spt           int,
   serial_lvl           int,
   serial_scy           int,
   serial_set           int,
   attendance_crs       enum('DAY','CLASS') not null default 'DAY',
   status_crs           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_crs)
)
type = innodb;

/*==============================================================*/
/* Table: course_director                                       */
/*==============================================================*/
create table course_director
(
   serial_emp           int,
   serial_crs           int,
   status_crd           enum('ACTIVE','INACTIVE') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: credit_card                                           */
/*==============================================================*/
create table credit_card
(
   serial_ccd           int not null auto_increment,
   name_ccd             varchar(200) not null,
   status_ccd           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_ccd)
)
type = innodb;

/*==============================================================*/
/* Table: currency                                              */
/*==============================================================*/
create table currency
(
   serial_crr           int not null auto_increment,
   abrevation_crr       varchar(4),
   name_crr             varchar(300) not null,
   status_crr           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_crr)
)
type = innodb;

/*==============================================================*/
/* Table: current_deferred                                      */
/*==============================================================*/
create table current_deferred
(
   serial_cdf           int not null auto_increment,
   serial_deb           int,
   total_quotas_cdf     int not null,
   quota_amount_cdf     decimal(6,2) not null,
   paid_quotas_cdf      int not null,
   last_month_paid_quota_cdf varchar(3),
   status_cdf           enum('ACTIVE','INACTIVE','PAID') not null default 'ACTIVE',
   primary key (serial_cdf)
)
type = innodb;

/*==============================================================*/
/* Table: degree                                                */
/*==============================================================*/
create table degree
(
   serial_dgr           int not null auto_increment,
   name_dgr             varchar(255) not null,
   status_dgr           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_dgr)
)
type = innodb;

/*==============================================================*/
/* Table: discipline                                            */
/*==============================================================*/
create table discipline
(
   serial_prd           int not null,
   serial_std           int not null,
   serial_spt           int not null,
   serial_lvl           int not null,
   serial_scy           int not null,
   serial_set           int not null,
   supervisor_grade_dsc decimal(5,2) default null,
   subjects_grade_dsc   decimal(5,2) default null,
   general_grade_dsc    decimal(5,2) default null,
   primary key (serial_prd, serial_std, serial_spt, serial_lvl, serial_scy, serial_set)
)
type = innodb;

/*==============================================================*/
/* Table: employee                                              */
/*==============================================================*/
create table employee
(
   serial_emp           int not null auto_increment,
   serial_tdg           int,
   serial_usr           int not null,
   serial_grd           int,
   serial_mdg           int,
   serial_ste           int,
   serial_cou           int,
   serial_nnt           int,
   serial_tst           int,
   serial_unv           int,
   serial_tmd           int,
   serial_dgr           int,
   id_emp               varchar(13) not null,
   type_emp             set('TEACHING','ADMINISTRATIVE','SERVICES'),
   status_emp           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   first_name_emp       varchar(255) not null,
   last_name_emp        varchar(255) not null,
   specialty_emp        varchar(150),
   gender_emp           enum('MALE','FEMALE') not null,
   marital_status_emp   enum('SINGLE','MARRIED','DIVORCED','WIDOWED','UNMARRIED PARTNERS'),
   birthdate_emp        date not null,
   address_emp          text not null,
   city_emp             varchar(150) not null,
   parish_emp           varchar(100),
   sector_emp           varchar(50),
   phone_emp            varchar(13) not null,
   phone2_emp           varchar(13),
   phone3_emp           varchar(13),
   cellphone_emp        varchar(13),
   email_emp            varchar(150),
   family_dependents_emp int,
   student_dependents_emp int,
   teaching_since_tea_emp date,
   seniority_university_tea_emp int,
   date_start_in_school_emp date not null,
   primary key (serial_emp)
)
type = innodb;

/*==============================================================*/
/* Table: employee_area                                         */
/*==============================================================*/
create table employee_area
(
   serial_aca           int not null,
   serial_emp           int not null,
   is_director_eba      enum('YES','NO') default 'NO',
   status_eba           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_aca, serial_emp)
)
type = innodb;

/*==============================================================*/
/* Table: financial_institution                                 */
/*==============================================================*/
create table financial_institution
(
   serial_fin           int not null auto_increment,
   name_fin             varchar(255) not null,
   phone1_fin           varchar(15) not null,
   phone2_fin           varchar(15) not null,
   status_fin           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_fin)
)
type = innodb;

/*==============================================================*/
/* Table: general_activity                                      */
/*==============================================================*/
create table general_activity
(
   serial_gac           int not null auto_increment,
   title_gac            varchar(50) not null,
   description_gac      text not null,
   create_date_gac      timestamp not null,
   from_date_gac        timestamp not null,
   to_date_gac          timestamp not null,
   type_gac             enum('GENERAL','PERSONAL') not null default 'GENERAL',
   attachment_gac       varchar(128),
   filename_gac         varchar(128),
   status_gac           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_gac)
)
type = innodb;

/*==============================================================*/
/* Table: general_activity_attendees                            */
/*==============================================================*/
create table general_activity_attendees
(
   serial_gaa           int not null auto_increment,
   serial_scy           int,
   serial_gac           int,
   type_gaa             enum('ALL','SECTION','COURSE','PERSONAL','TEACHER','EMPLOYEE','ACADEMIC_AREA') not null,
   remote_id_gaa        int,
   comments_gaa         text,
   status_gaa           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_gaa)
)
type = innodb;

/*==============================================================*/
/* Table: general_discipline_log                                */
/*==============================================================*/
create table general_discipline_log
(
   serial_usr           int,
   serial_chr           int,
   serial_prd           int,
   serial_std           int,
   serial_spt           int,
   serial_lvl           int,
   serial_scy           int,
   serial_set           int,
   change_date_gdl      timestamp not null,
   last_grade_gdl       decimal(5,2) not null,
   comment_gdl          text
)
type = innodb;

/*==============================================================*/
/* Table: grade_change_log                                      */
/*==============================================================*/
create table grade_change_log
(
   serial_usr           int,
   serial_chr           int,
   serial_sbc           int,
   serial_att           int,
   serial_prd           int,
   serial_gct           int,
   serial_act           int,
   serial_std           int,
   serial_crs           int,
   change_date_gcl      timestamp not null,
   last_grade_gcl       decimal(5,2),
   comment_gcl          text
)
type = innodb;

/*==============================================================*/
/* Table: grade_criteria                                        */
/*==============================================================*/
create table grade_criteria
(
   serial_gct           int not null auto_increment,
   name_gct             varchar(256) not null,
   description_gct      text not null,
   status_gct           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_gct)
)
type = innodb;

/*==============================================================*/
/* Table: grade_subject_score                                   */
/*==============================================================*/
create table grade_subject_score
(
   serial_ygs           int,
   serial_std           int,
   serial_spt           int,
   serial_lvl           int,
   serial_scy           int,
   serial_set           int,
   score_gss            decimal(5,2),
   status_gss           enum('ACTIVE','INACTIVE') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: group_hour                                            */
/*==============================================================*/
create table group_hour
(
   serial_gph           int not null auto_increment,
   name_gph             varchar(100) not null,
   description_gph      text,
   status_gph           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_gph)
)
type = innodb;

/*==============================================================*/
/* Table: group_hour_level                                      */
/*==============================================================*/
create table group_hour_level
(
   serial_gph           int not null,
   serial_lvl           int not null,
   serial_scy           int not null,
   serial_set           int not null,
   working_days_ghl     set('MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY','SUNDAY'),
   status_ghl           enum('ACTIVE','INACTIVE') default 'ACTIVE',
   primary key (serial_gph, serial_lvl, serial_scy, serial_set)
)
type = innodb;

/*==============================================================*/
/* Table: guardian                                              */
/*==============================================================*/
create table guardian
(
   serial_grd           int not null auto_increment,
   serial_usr           int not null,
   serial_emp           int,
   id_grd               varchar(13) not null,
   first_name_grd       varchar(512) not null,
   last_name_grd        varchar(512) not null,
   birthdate_grd        date not null,
   gender_grd           enum('MALE','FEMALE') not null,
   address_grd          text not null,
   phone_grd            varchar(13) not null,
   status_grd           enum('ACTIVE','INACTIVE','BLOCKED') not null default 'ACTIVE',
   occupation_grd       varchar(50),
   company_name_grd     varchar(100),
   company_activity_grd varchar(80),
   company_phone_grd    varchar(13),
   primary key (serial_grd)
)
type = innodb;

/*==============================================================*/
/* Table: guest                                                 */
/*==============================================================*/
create table guest
(
   serial_gst           int not null auto_increment,
   id_gst               varchar(20) not null,
   first_name_gst       varchar(128) not null,
   last_name_gst        varchar(128) not null,
   birthdate_gst        date not null,
   gender_gst           enum('MALE','FEMALE') not null,
   status_gst           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_gst)
)
type = innodb;

/*==============================================================*/
/* Table: hour                                                  */
/*==============================================================*/
create table hour
(
   serial_hrs           int not null auto_increment,
   start_hrs            time not null,
   end_hrs              time not null,
   status_hrs           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_hrs)
)
type = innodb;

/*==============================================================*/
/* Table: hour_by_group                                         */
/*==============================================================*/
create table hour_by_group
(
   serial_hbg           int not null auto_increment,
   serial_hrs           int,
   serial_gph           int,
   status_hbg           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   type_hbg             enum('NORMAL','LUNCH') not null default 'NORMAL',
   primary key (serial_hbg)
)
type = innodb;

/*==============================================================*/
/* Table: incident                                              */
/*==============================================================*/
create table incident
(
   serial_inc           int not null auto_increment,
   serial_usr           int,
   use_serial_usr       int,
   date_inc             date not null,
   report_date_inc      date not null,
   description_inc      text not null,
   primary key (serial_inc)
)
type = innodb;

/*==============================================================*/
/* Table: income_stock                                          */
/*==============================================================*/
create table income_stock
(
   serial_ist           int not null auto_increment,
   serial_prv           int,
   serial_usr           int,
   serial_mti           int,
   income_ist           decimal(5,2) not null,
   cost_ist             decimal(5,2) not null,
   income_date_ist      date not null,
   available_ist        decimal(5,2) not null,
   primary key (serial_ist)
)
type = innodb;

/*==============================================================*/
/* Table: invoice                                               */
/*==============================================================*/
create table invoice
(
   serial_phy           int not null auto_increment,
   payment_date_phy     timestamp not null,
   subtotal_phy         decimal(6,2) not null,
   taxes_phy            decimal(6,2) not null,
   total_phy            decimal(6,2) not null,
   id_paying_phy        varchar(15) not null,
   name_paying_phy      varchar(512) not null,
   phone_paying_phy     varchar(15),
   addrees_paying_phy   varchar(1024),
   physical_number_phy  varchar(128) not null,
   status_phy           enum('ACTIVE','INACTIVE','PAID','VOID') not null default 'ACTIVE',
   primary key (serial_phy)
)
type = innodb;

/*==============================================================*/
/* Table: invoice_detail                                        */
/*==============================================================*/
create table invoice_detail
(
   serial_cdf           int,
   serial_deb           int,
   serial_phy           int,
   status_psd           enum('ACTIVE','INACTIVE') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: item_category                                         */
/*==============================================================*/
create table item_category
(
   serial_ict           int not null auto_increment,
   name_ict             varchar(160) not null,
   description_ict      text not null,
   status_ict           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_ict)
)
type = innodb;

/*==============================================================*/
/* Table: language                                              */
/*==============================================================*/
create table language
(
   serial_lng           int not null auto_increment,
   abbreviation_lng     varchar(3),
   name_lng             varchar(50) not null,
   primary key (serial_lng)
)
type = innodb;

/*==============================================================*/
/* Table: level                                                 */
/*==============================================================*/
create table level
(
   serial_lvl           int not null auto_increment,
   name_lvl             varchar(150) not null,
   description_lvl      text,
   status_lvl           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_lvl)
)
type = innodb;

/*==============================================================*/
/* Table: level_section_year                                    */
/*==============================================================*/
create table level_section_year
(
   serial_pgy           int,
   serial_lvl           int not null,
   serial_scy           int not null,
   serial_set           int not null,
   status_lsy           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_lvl, serial_scy, serial_set)
)
type = innodb;

/*==============================================================*/
/* Table: level_section_year_specialty                          */
/*==============================================================*/
create table level_section_year_specialty
(
   serial_spt           int not null,
   serial_lvl           int not null,
   serial_scy           int not null,
   serial_set           int not null,
   status_lss           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_spt, serial_lvl, serial_scy, serial_set)
)
type = innodb;

/*==============================================================*/
/* Table: maintenance_item                                      */
/*==============================================================*/
create table maintenance_item
(
   serial_mti           int not null auto_increment,
   serial_ict           int,
   name_mti             varchar(160) not null,
   description_mti      text not null,
   brand_mti            varchar(128) not null,
   status_mti           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_mti)
)
type = innodb;

/*==============================================================*/
/* Table: master_degree                                         */
/*==============================================================*/
create table master_degree
(
   serial_mdg           int not null auto_increment,
   name_mdg             varchar(255) not null,
   status_mdg           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_mdg)
)
type = innodb;

/*==============================================================*/
/* Table: medical_file                                          */
/*==============================================================*/
create table medical_file
(
   serial_mdf           int not null auto_increment,
   serial_usr           int,
   serial_gst           int,
   chronic_disease_mdf  text,
   weight_mdf           decimal(5,2) not null,
   height_mdf           decimal(5,2) not null,
   allergy_mdf          text,
   allergy_medication_mdf text,
   reaction_medicine_mdf text,
   fever_medication_mdf text not null,
   headache_medication_mdf text not null,
   stomachache_medication_mdf text not null,
   registration_date_mdf date not null,
   status_mdf           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_mdf)
)
type = innodb;

/*==============================================================*/
/* Table: message                                               */
/*==============================================================*/
create table message
(
   serial_msg           int not null auto_increment,
   serial_usr_receive   int,
   serial_prf           int,
   serial_usr_send      int,
   type_msg             enum('PRIVATE','PUBLIC') not null default 'PUBLIC',
   user_from_name_msg   varchar(256) not null,
   user_to_name_msg     varchar(256) not null,
   subject_msg          varchar(128) not null,
   message_msg          text not null,
   checked_msg          enum('YES','NO') not null default 'NO',
   saved_msg            enum('YES','NO') default 'NO',
   deleted_msg          enum('YES','NO') default 'NO',
   removed_permanently_msg enum('YES','NO') default 'NO',
   send_date_msg        timestamp,
   check_date_msg       timestamp,
   filename_msg         varchar(50),
   attachment_msg       varchar(50),
   priority_msg         enum('URGENT','NORMAL') not null default 'NORMAL',
   primary key (serial_msg)
)
type = innodb;

/*==============================================================*/
/* Table: message_between_profiles                              */
/*==============================================================*/
create table message_between_profiles
(
   serial_prf           int not null,
   pro_serial_prf       int not null,
   status_mbp           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_prf, pro_serial_prf)
)
type = innodb;

/*==============================================================*/
/* Table: message_thread                                        */
/*==============================================================*/
create table message_thread
(
   serial_mth           int not null auto_increment,
   serial_usr           int,
   start_date_mth       timestamp not null,
   primary key (serial_mth)
)
type = innodb;

/*==============================================================*/
/* Table: message_thread_messages                               */
/*==============================================================*/
create table message_thread_messages
(
   serial_mtm           int not null auto_increment,
   serial_mth           int,
   serial_msg           int,
   primary key (serial_mtm)
)
type = innodb;

/*==============================================================*/
/* Table: ministry_subject                                      */
/*==============================================================*/
create table ministry_subject
(
   serial_msb           int not null auto_increment,
   name_msb             varchar(256) not null,
   description_msb      text not null,
   status_msb           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_msb)
)
type = innodb;

/*==============================================================*/
/* Table: nationality                                           */
/*==============================================================*/
create table nationality
(
   serial_nnt           int not null auto_increment,
   name_nnt             varchar(255) not null,
   status_nnt           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_nnt)
)
type = innodb;

/*==============================================================*/
/* Table: optional_subject                                      */
/*==============================================================*/
create table optional_subject
(
   serial_osb           int not null auto_increment,
   serial_csb           int,
   serial_pgy           int,
   serial_aca           int,
   serial_emp           int,
   status_osb           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   grade_type_sbc       enum('QUALITATIVE','QUANTITATIVE') not null default 'QUANTITATIVE',
   primary key (serial_osb)
)
type = innodb;

/*==============================================================*/
/* Table: optional_subject_level                                */
/*==============================================================*/
create table optional_subject_level
(
   serial_osb           int,
   serial_spt           int,
   serial_lvl           int,
   serial_scy           int,
   serial_set           int,
   status_osl           enum('ACTIVE','INACTIVE') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: optional_subject_period                               */
/*==============================================================*/
create table optional_subject_period
(
   serial_prd           int not null,
   serial_osb           int not null,
   status_osp           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   weight_osp           decimal(5,2) not null,
   primary key (serial_prd, serial_osb)
)
type = innodb;

/*==============================================================*/
/* Table: optional_subject_retest                               */
/*==============================================================*/
create table optional_subject_retest
(
   serial_osr           int not null auto_increment,
   serial_prd           int,
   serial_osb           int,
   description_osr      text not null,
   sent_date_osr        date not null,
   retest_date_osr      date not null,
   weight_osr           decimal(3,2) not null,
   status_osr           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_osr)
)
type = innodb;

/*==============================================================*/
/* Table: optional_subject_retest_student                       */
/*==============================================================*/
create table optional_subject_retest_student
(
   serial_std           int,
   serial_osr           int,
   grade_org            decimal(5,2),
   status_org           enum('ACTIVE','INACTIVE') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: opt_activity                                          */
/*==============================================================*/
create table opt_activity
(
   serial_opa           int not null auto_increment,
   name_opa             varchar(256) not null,
   description_opa      text not null,
   send_date_opa        timestamp not null,
   due_date_opa         timestamp not null,
   status_opa           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_opa)
)
type = innodb;

/*==============================================================*/
/* Table: opt_activity_applied_criterias                        */
/*==============================================================*/
create table opt_activity_applied_criterias
(
   serial_opa           int not null,
   serial_gct           int not null,
   serial_osb           int not null,
   serial_att           int not null,
   serial_prd           int not null,
   weight_oaa           decimal(5,2),
   status_oaa           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_opa, serial_gct, serial_osb, serial_att, serial_prd)
)
type = innodb;

/*==============================================================*/
/* Table: opt_activity_attachment                               */
/*==============================================================*/
create table opt_activity_attachment
(
   serial_oat           int not null auto_increment,
   serial_opa           int,
   name_oat             varchar(256) not null,
   filename_oat         varchar(256) not null,
   status_oat           enum('ACTIVE','INACTIVE','DELETED') not null default 'ACTIVE',
   primary key (serial_oat)
)
type = innodb;

/*==============================================================*/
/* Table: opt_grade_change_log                                  */
/*==============================================================*/
create table opt_grade_change_log
(
   serial_usr           int,
   serial_chr           int,
   serial_opa           int,
   serial_gct           int,
   serial_osb           int,
   serial_att           int,
   serial_prd           int,
   serial_std           int,
   opt_change_date_ogc  timestamp not null,
   opt_last_grade_ogc   decimal(5,2),
   opt_comment_ogc      text
)
type = innodb;

/*==============================================================*/
/* Table: opt_student_activity_attachment                       */
/*==============================================================*/
create table opt_student_activity_attachment
(
   serial_oth           int not null auto_increment,
   serial_opa           int,
   serial_std           int,
   name_oth             varchar(256) not null,
   filename_oth         varchar(256) not null,
   status_oth           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_oth)
)
type = innodb;

/*==============================================================*/
/* Table: opt_student_criteria_grade                            */
/*==============================================================*/
create table opt_student_criteria_grade
(
   serial_opa           int not null,
   serial_gct           int not null,
   serial_osb           int not null,
   serial_att           int not null,
   serial_prd           int not null,
   serial_std           int not null,
   grade_osg            decimal(5,2) default null,
   is_complete_osg      enum('YES','NO') not null default 'NO',
   activity_grade_part_osg decimal(6,2),
   status_osg           enum('ACTIVE','INACTIVE','NOT_APPLY') not null default 'ACTIVE',
   primary key (serial_opa, serial_gct, serial_osb, serial_att, serial_prd, serial_std)
)
type = innodb;

/*==============================================================*/
/* Table: opt_subject_period_activity_type                      */
/*==============================================================*/
create table opt_subject_period_activity_type
(
   serial_att           int not null,
   serial_prd           int not null,
   serial_osb           int not null,
   weight_osa           decimal(5,2) not null,
   due_min_days_osa     int not null,
   due_max_grade_osa    int,
   status_osa           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_att, serial_prd, serial_osb)
)
type = innodb;

/*==============================================================*/
/* Table: opt_subject_year_activity_criteria_period             */
/*==============================================================*/
create table opt_subject_year_activity_criteria_period
(
   serial_gct           int not null,
   serial_osb           int not null,
   serial_att           int not null,
   serial_prd           int not null,
   status_oac           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_gct, serial_osb, serial_att, serial_prd)
)
type = innodb;

/*==============================================================*/
/* Table: opt_subject_year_grade_criteria                       */
/*==============================================================*/
create table opt_subject_year_grade_criteria
(
   serial_gct           int not null,
   serial_osb           int not null,
   status_oyc           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_gct, serial_osb)
)
type = innodb;

/*==============================================================*/
/* Table: payment_concept                                       */
/*==============================================================*/
create table payment_concept
(
   serial_pct           int not null auto_increment,
   name_pct             varchar(200) not null,
   status_pct           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_pct)
)
type = innodb;

/*==============================================================*/
/* Table: payment_detail                                        */
/*==============================================================*/
create table payment_detail
(
   serial_pym           int,
   serial_ccd           int,
   serial_fin           int,
   serial_phy           int,
   description_pdt      varchar(128) not null,
   document_number_pdt  varchar(128),
   amount_pdt           decimal(6,2) not null,
   kinship_pdt          varchar(80),
   owner_pdt            varchar(300),
   status_pdt           enum('ACTIVE','INACTIVE') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: payment_method                                        */
/*==============================================================*/
create table payment_method
(
   serial_pym           int not null auto_increment,
   name_pym             varchar(128) not null,
   requires_owner_info_pym enum('YES','NO') not null default 'NO',
   requires_financial_pym enum('YES','NO') not null default 'NO',
   requires_credit_card_pym enum('YES','NO') not null default 'NO',
   status_pym           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_pym)
)
type = innodb;

/*==============================================================*/
/* Table: period                                                */
/*==============================================================*/
create table period
(
   serial_prd           int not null auto_increment,
   serial_pgy           int,
   name_prd             varchar(255) not null,
   start_date_prd       date not null,
   end_date_prd         date not null,
   max_grade_date_prd   date not null,
   status_prd           enum('ACTIVE','INACTIVE','BLOCKED','ENDED') not null default 'ACTIVE',
   min_grade_prd        decimal(5,2) not null,
   max_grade_prd        decimal(5,2) not null,
   warning_grade_prd    decimal(5,2) not null,
   weight_prd           decimal(5,2) not null,
   primary key (serial_prd)
)
type = innodb;

/*==============================================================*/
/* Table: period_group_year                                     */
/*==============================================================*/
create table period_group_year
(
   serial_pgy           int not null auto_increment,
   serial_scy           int,
   serial_cpd           int,
   name_pgy             varchar(255),
   status_pgy           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_pgy)
)
type = innodb;

/*==============================================================*/
/* Table: pre_registration                                      */
/*==============================================================*/
create table pre_registration
(
   serial_prt           int not null auto_increment,
   serial_nnt           int,
   serial_usr           int,
   serial_dgr           int,
   serial_spt           int,
   serial_lvl           int,
   serial_scy           int,
   serial_set           int,
   first_name_prt       varchar(512) not null,
   last_name_prt        varchar(512) not null,
   relationship_prt     enum('PARENT','SIBLING','GRANDPARENT','AUNT_UNCLE','OTHER') not null,
   birthdate_prt        date not null,
   gender_prt           enum('MALE','FEMALE') not null,
   address_prt          text not null,
   phone_prt            varchar(13) not null,
   status_prt           enum('ACCEPTED','DENIED','STAND_BY','PROCESSED') not null default 'STAND_BY',
   first_name_father_prt varchar(100),
   last_name_father_prt varchar(100),
   first_name_mother_prt varchar(100),
   last_name_mother_prt varchar(100),
   city_birth_prt       varchar(100) not null,
   blood_type_prt       varchar(10) not null,
   allergies_prt        text,
   lives_with_prt       enum('PARENT','SIBLING','GRANDPARENT','AUNT_UNCLE','OTHER') not null,
   photo_prt            varchar(1024) not null,
   rep_first_name_prt   varchar(100) not null,
   rep_last_name_prt    varchar(100) not null,
   rep_relationship_prt enum('PARENT','SIBLING','GRANDPARENT','AUNT_UNCLE','OTHER') not null,
   rep_birthdate_prt    date not null,
   rep_city_birth_prt   varchar(100) not null,
   rep_marital_status_prt enum('SINGLE','MARRIED','DIVORCED','WIDOWED','UNMARRIED PARTNERS') not null,
   rep_occupation_prt   varchar(100) not null,
   rep_address_prt      text not null,
   rep_phone_prt        varchar(13) not null,
   rep_mobile_prt       varchar(13),
   rep_company_name_prt varchar(80),
   rep_company_activity_prt text,
   rep_company_phone_prt varchar(13),
   rep_photo_prt        varchar(1024) not null,
   rep_gender_prt       enum('MALE','FEMALE') not null,
   rep_id_prt           varchar(13) not null,
   primary key (serial_prt)
)
type = innodb;

/*==============================================================*/
/* Table: pre_registration_period                               */
/*==============================================================*/
create table pre_registration_period
(
   serial_scy           int,
   start_date_prp       date not null,
   end_date_prp         date not null,
   status_prp           enum('ACTIVE','INACTIVE','CLOSED','OPEN') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: process                                               */
/*==============================================================*/
create table process
(
   serial_prc           int not null auto_increment,
   prc_serial_prc       int,
   name_prc             varchar(150) not null,
   link_prc             varchar(1024) not null,
   weight_prc           decimal(5,1) not null,
   status_prc           enum('LOCKABLE','NON-LOCKABLE') not null default 'LOCKABLE',
   primary key (serial_prc)
)
type = innodb;

/*==============================================================*/
/* Table: profile                                               */
/*==============================================================*/
create table profile
(
   serial_prf           int not null auto_increment,
   name_prf             varchar(150) not null,
   type_prf             enum('INTERNAL','EXTERNAL') not null,
   status_prf           enum('ACTIVE','INACTIVE') not null,
   owner_prf            enum('SYSTEM','USER') not null default 'USER',
   primary key (serial_prf)
)
type = innodb;

/*==============================================================*/
/* Table: profile_process                                       */
/*==============================================================*/
create table profile_process
(
   serial_prf           int,
   serial_prc           int,
   status_ppr           enum('ACTIVE','BLOCKED') default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: provider                                              */
/*==============================================================*/
create table provider
(
   serial_prv           int not null auto_increment,
   name_prv             varchar(160) not null,
   id_prv               varchar(15) not null,
   address_prv          text not null,
   phone1_prv           varchar(16) not null,
   phone2_prv           varchar(16),
   contact_name_prv     varchar(255) not null,
   status_prv           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_prv)
)
type = innodb;

/*==============================================================*/
/* Table: psychological_file                                    */
/*==============================================================*/
create table psychological_file
(
   serial_pyf           int not null auto_increment,
   serial_std           int,
   therapy_pyf          enum('PSYCHOLOGICAL','VERBAL','VISUAL','LEARNING','BEHAVIOUR','AUDITORY','FAMILY','OTHER'),
   discharged_pyf       enum('YES','NO'),
   diagnosis_pyf        text,
   diagnosed_by_pyf     text,
   therapy_time_pyf     text,
   abandon_reason_pyf   text,
   medication_pyf       text,
   therapeutic_center_pyf varchar(512),
   registration_date_pyf date not null,
   status_pyf           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_pyf)
)
type = innodb;

/*==============================================================*/
/* Table: qualifying_document                                   */
/*==============================================================*/
create table qualifying_document
(
   serial_qdc           int not null auto_increment,
   name_qdc             varchar(256) not null,
   description_qdc      text not null,
   status_qdc           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_qdc)
)
type = innodb;

/*==============================================================*/
/* Table: qualitative_equivalence                               */
/*==============================================================*/
create table qualitative_equivalence
(
   serial_qeq           int not null auto_increment,
   serial_scy           int,
   lower_percentage_qeq decimal(5,2) not null,
   higher_percentage_qeq decimal(5,2) not null,
   name_qeq             varchar(50) not null,
   code_qeq             varchar(15) not null,
   status_qeq           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_qeq)
)
type = innodb;

/*==============================================================*/
/* Table: request_detail                                        */
/*==============================================================*/
create table request_detail
(
   serial_ist           int,
   serial_srq           int,
   item_quantity_rdt    decimal(5,2) not null,
   status_rdt           enum('ACTIVE','INACTIVE') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: route                                                 */
/*==============================================================*/
create table route
(
   serial_rot           int not null auto_increment,
   code_rot             varchar(10) not null,
   description_rot      text not null,
   status_rot           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_rot)
)
type = innodb;

/*==============================================================*/
/* Table: school_setup                                          */
/*==============================================================*/
create table school_setup
(
   serial_ste           int,
   serial_crr           int,
   name_sst             varchar(1024) not null,
   city_sst             varchar(100) not null,
   address_sst          text not null,
   phone1_sst           varchar(20) not null,
   phone2_sst           varchar(20),
   phone3_sst           varchar(20),
   contact_name_sst     varchar(250) not null,
   contact_phone_sst    varchar(20) not null,
   logo_sst             varchar(100) not null,
   slogan_sst           varchar(300),
   main_color_sst       varchar(7) not null,
   secondary_color_sst  varchar(7) not null
)
type = innodb;

/*==============================================================*/
/* Table: school_year                                           */
/*==============================================================*/
create table school_year
(
   serial_scy           int not null auto_increment,
   start_date_scy       date not null,
   end_date_scy         date not null,
   status_scy           set('ACTIVE','CURRENT','ENDED','NEW','INACTIVE') not null default 'NEW',
   name_scy             varchar(150) not null,
   discipline_scy       enum('SUPERVISOR','TEACHERS','BOTH') not null,
   grade_precision_scy  int not null,
   supervisor_grade_weight_scy decimal(5,2) not null default 0,
   teacher_grade_weight_scy decimal(5,2) not null default 0,
   primary key (serial_scy)
)
type = innodb;

/*==============================================================*/
/* Table: section                                               */
/*==============================================================*/
create table section
(
   serial_set           int not null auto_increment,
   name_set             varchar(150) not null,
   description_set      text,
   status_set           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   type_set             enum('DAY','EVENING','NIGHT') not null default 'DAY',
   primary key (serial_set)
)
type = innodb;

/*==============================================================*/
/* Table: section_by_year                                       */
/*==============================================================*/
create table section_by_year
(
   serial_scy           int not null,
   serial_set           int not null,
   status_sby           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_scy, serial_set)
)
type = innodb;

/*==============================================================*/
/* Table: shift                                                 */
/*==============================================================*/
create table shift
(
   serial_sft           int not null auto_increment,
   name_sft             varchar(120) not null,
   description_sft      text not null,
   status_sft           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_sft)
)
type = innodb;

/*==============================================================*/
/* Table: specialty                                             */
/*==============================================================*/
create table specialty
(
   serial_spt           int not null auto_increment,
   name_spt             varchar(150) not null,
   description_spt      text,
   status_spt           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_spt)
)
type = innodb;

/*==============================================================*/
/* Table: state                                                 */
/*==============================================================*/
create table state
(
   serial_ste           int not null auto_increment,
   serial_cou           int,
   name_ste             varchar(100) not null,
   status_ste           enum('ACTIVE','INACTIVE') default 'ACTIVE',
   primary key (serial_ste)
)
type = innodb;

/*==============================================================*/
/* Table: stock_request                                         */
/*==============================================================*/
create table stock_request
(
   serial_srq           int not null auto_increment,
   serial_udt           int,
   serial_usr           int,
   description_srq      text not null,
   request_date_srq     date not null,
   status_srq           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_srq)
)
type = innodb;

/*==============================================================*/
/* Table: student                                               */
/*==============================================================*/
create table student
(
   serial_std           int not null auto_increment,
   serial_usr           int not null,
   serial_nnt           int,
   id_std               varchar(13) not null,
   first_name_std       varchar(255) not null,
   last_name_std        varchar(255) not null,
   birthdate_std        date not null,
   gender_std           enum('MALE','FEMALE') not null,
   address_std          text,
   phone_std            varchar(13),
   type_std             enum('NEW','OLD') not null default 'NEW',
   status_std           enum('ACTIVE','INACTIVE','BLOCKED') not null default 'INACTIVE',
   primary key (serial_std)
)
type = innodb;

/*==============================================================*/
/* Table: student_activity_attachment                           */
/*==============================================================*/
create table student_activity_attachment
(
   serial_saa           int not null auto_increment,
   name_saa             varchar(256) not null,
   filename_saa         varchar(256) not null,
   serial_std           int,
   serial_act           int,
   status_saa           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_saa)
)
type = innodb;

/*==============================================================*/
/* Table: student_by_course                                     */
/*==============================================================*/
create table student_by_course
(
   serial_std           int not null,
   serial_crs           int not null,
   status_stc           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_std, serial_crs)
)
type = innodb;

/*==============================================================*/
/* Table: student_criteria_grade                                */
/*==============================================================*/
create table student_criteria_grade
(
   serial_sbc           int not null,
   serial_att           int not null,
   serial_prd           int not null,
   serial_gct           int not null,
   serial_act           int not null,
   serial_std           int not null,
   serial_crs           int not null,
   grade_scg            decimal(5,2) default null,
   is_complete_scg      enum('YES','NO') not null default 'NO',
   activity_grade_part_scg decimal(6,2),
   status_scg           enum('ACTIVE','INACTIVE','NOT_APPLY') not null default 'ACTIVE',
   primary key (serial_sbc, serial_att, serial_prd, serial_gct, serial_act, serial_std, serial_crs)
)
type = innodb;

/*==============================================================*/
/* Table: student_guardian                                      */
/*==============================================================*/
create table student_guardian
(
   serial_std           int not null,
   serial_grd           int not null,
   relationship_stg     enum('PARENT','SIBLING','GRANDPARENT','AUNT_UNCLE','OTHER') not null,
   legal_guardian_stg   enum('YES','NO') not null default 'NO',
   status_stg           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_std, serial_grd)
)
type = innodb;

/*==============================================================*/
/* Table: student_optional_subject                              */
/*==============================================================*/
create table student_optional_subject
(
   serial_osb           int not null,
   serial_std           int not null,
   status_sos           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_osb, serial_std)
)
type = innodb;

/*==============================================================*/
/* Table: student_year                                          */
/*==============================================================*/
create table student_year
(
   matricule_number_sty varchar(20),
   serial_std           int not null,
   serial_spt           int not null,
   serial_lvl           int not null,
   serial_scy           int not null,
   serial_set           int not null,
   status_sty           enum('ACCEPTED','REGISTERED','MATRICULE') not null,
   primary key (serial_std, serial_spt, serial_lvl, serial_scy, serial_set)
)
type = innodb;

/*==============================================================*/
/* Table: student_year_debts                                    */
/*==============================================================*/
create table student_year_debts
(
   serial_deb           int not null auto_increment,
   serial_std           int,
   serial_pct           int,
   serial_spt           int,
   serial_lvl           int,
   serial_scy           int,
   serial_set           int,
   total_deb            decimal(9,2) not null,
   total_taxes_deb      decimal(9,2) not null,
   article_quantity_deb decimal(5,2),
   start_date_deb       date not null,
   due_date_deb         date not null,
   status_deb           enum('PENDING','PAID','INACTIVE') not null default 'PENDING',
   primary key (serial_deb)
)
type = innodb;

/*==============================================================*/
/* Table: student_year_document                                 */
/*==============================================================*/
create table student_year_document
(
   serial_yqd           int,
   serial_std           int,
   serial_spt           int,
   serial_lvl           int,
   serial_scy           int,
   serial_set           int,
   delivered_syd        enum('YES','NO') not null default 'NO',
   status_syd           enum('ACTIVE','INACTIVE') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: student_year_special_grade                            */
/*==============================================================*/
create table student_year_special_grade
(
   serial_ysg           int not null,
   serial_std           int not null,
   serial_spt           int not null,
   serial_lvl           int not null,
   serial_scy           int not null,
   serial_set           int not null,
   grade_sys            decimal(6,2),
   status_sys           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_ysg, serial_std, serial_spt, serial_lvl, serial_scy, serial_set)
)
type = innodb;

/*==============================================================*/
/* Table: subject                                               */
/*==============================================================*/
create table subject
(
   serial_sbj           int not null auto_increment,
   serial_csb           int,
   serial_spt           int,
   serial_lvl           int,
   serial_scy           int,
   serial_set           int,
   status_sbj           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_sbj)
)
type = innodb;

/*==============================================================*/
/* Table: subject_course                                        */
/*==============================================================*/
create table subject_course
(
   serial_sbc           int not null auto_increment,
   serial_sbj           int,
   serial_crs           int,
   serial_aca           int,
   serial_emp           int,
   status_sbc           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   grade_type_sbc       enum('QUALITATIVE','QUANTITATIVE') not null default 'QUANTITATIVE',
   hours_week_sbc       int not null,
   primary key (serial_sbc)
)
type = innodb;

/*==============================================================*/
/* Table: subject_course_period                                 */
/*==============================================================*/
create table subject_course_period
(
   serial_prd           int not null,
   serial_sbc           int not null,
   status_scp           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   weight_scp           decimal(5,2),
   primary key (serial_prd, serial_sbc)
)
type = innodb;

/*==============================================================*/
/* Table: subject_course_retest                                 */
/*==============================================================*/
create table subject_course_retest
(
   serial_scr           int not null auto_increment,
   serial_prd           int,
   serial_sbc           int,
   description_scr      text not null,
   sent_date_scr        date not null,
   retest_date_scr      date not null,
   weight_scr           decimal(3,2) not null,
   status_scr           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_scr)
)
type = innodb;

/*==============================================================*/
/* Table: subject_course_retest_student                         */
/*==============================================================*/
create table subject_course_retest_student
(
   serial_std           int,
   serial_scr           int,
   grade_srg            decimal(5,2) not null,
   status_srg           enum('ACTIVE','INACTIVE') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: subject_ministry_equivalence                          */
/*==============================================================*/
create table subject_ministry_equivalence
(
   serial_emp           int,
   serial_msb           int,
   serial_csb           int,
   serial_spt           int,
   serial_lvl           int,
   serial_scy           int,
   serial_set           int,
   status_sme           enum('ACTIVE','INACTIVE') not null default 'ACTIVE'
)
type = innodb;

/*==============================================================*/
/* Table: subject_period_activity_type                          */
/*==============================================================*/
create table subject_period_activity_type
(
   serial_att           int not null,
   serial_prd           int not null,
   serial_sbc           int not null,
   weight_spa           decimal(5,2),
   due_min_days_spa     int not null,
   due_max_grade_spa    int not null,
   status_spa           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_att, serial_prd, serial_sbc)
)
type = innodb;

/*==============================================================*/
/* Table: subject_year_activity_criteria_period                 */
/*==============================================================*/
create table subject_year_activity_criteria_period
(
   serial_att           int not null,
   serial_prd           int not null,
   serial_sbc           int not null,
   serial_sbj           int not null,
   serial_gct           int not null,
   status_acp           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_att, serial_prd, serial_sbc, serial_sbj, serial_gct)
)
type = innodb;

/*==============================================================*/
/* Table: subject_year_grade_criteria                           */
/*==============================================================*/
create table subject_year_grade_criteria
(
   serial_sbj           int not null,
   serial_gct           int not null,
   status_sgc           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_sbj, serial_gct)
)
type = innodb;

/*==============================================================*/
/* Table: syllabus_files                                        */
/*==============================================================*/
create table syllabus_files
(
   serial_syf           int not null auto_increment,
   serial_sbc           int,
   serial_osb           int,
   name_syf             varchar(256) not null,
   description_syf      text not null,
   filename_syf         varchar(128) not null,
   status_syf           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_syf)
)
type = innodb;

/*==============================================================*/
/* Table: syllabus_files_change_log                             */
/*==============================================================*/
create table syllabus_files_change_log
(
   serial_syf           int,
   serial_usr           int,
   change_date_scl      timestamp not null,
   old_data_scl         text not null
)
type = innodb;

/*==============================================================*/
/* Table: taxes                                                 */
/*==============================================================*/
create table taxes
(
   serial_tax           int not null auto_increment,
   name_tax             varchar(256) not null,
   description_tax      text not null,
   status_tax           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_tax)
)
type = innodb;

/*==============================================================*/
/* Table: teacher_degree                                        */
/*==============================================================*/
create table teacher_degree
(
   serial_tdg           int not null auto_increment,
   name_tdg             varchar(255) not null,
   status_tdg           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_tdg)
)
type = innodb;

/*==============================================================*/
/* Table: teacher_hours_year                                    */
/*==============================================================*/
create table teacher_hours_year
(
   serial_thy           int not null auto_increment,
   serial_emp           int,
   serial_scy           int,
   start_hour_thy       time not null,
   end_hour_thy         time not null,
   status_thy           enum('ACTIVE','INACTIVE','ASSIGNED') not null default 'ACTIVE',
   labor_day_thy        enum('MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY','SUNDAY') not null,
   primary key (serial_thy)
)
type = innodb;

/*==============================================================*/
/* Table: teacher_master_degree                                 */
/*==============================================================*/
create table teacher_master_degree
(
   serial_tmd           int not null auto_increment,
   name_tmd             varchar(255) not null,
   status_tmd           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_tmd)
)
type = innodb;

/*==============================================================*/
/* Table: teacher_specialty                                     */
/*==============================================================*/
create table teacher_specialty
(
   serial_tst           int not null auto_increment,
   name_tst             varchar(255) not null,
   status_tst           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_tst)
)
type = innodb;

/*==============================================================*/
/* Table: university                                            */
/*==============================================================*/
create table university
(
   serial_unv           int not null auto_increment,
   name_unv             varchar(255) not null,
   status_unv           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_unv)
)
type = innodb;

/*==============================================================*/
/* Table: user                                                  */
/*==============================================================*/
create table user
(
   serial_usr           int not null auto_increment,
   serial_emp           int,
   serial_grd           int,
   serial_std           int,
   username_usr         varchar(150) not null,
   password_usr         varchar(300),
   photo_usr            varchar(1024),
   status_usr           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_usr)
)
type = innodb;

/*==============================================================*/
/* Table: user_profile                                          */
/*==============================================================*/
create table user_profile
(
   serial_usr           int not null,
   serial_prf           int not null,
   status_upr           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_usr, serial_prf)
)
type = innodb;

/*==============================================================*/
/* Table: use_destination                                       */
/*==============================================================*/
create table use_destination
(
   serial_udt           int not null auto_increment,
   name_udt             varchar(200) not null,
   description_udt      text not null,
   status_udt           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_udt)
)
type = innodb;

/*==============================================================*/
/* Table: visits_medical_center                                 */
/*==============================================================*/
create table visits_medical_center
(
   serial_vmc           int not null auto_increment,
   serial_mdf           int,
   date_vmc             date not null,
   reason_vmc           text not null,
   diagnosis_vmc        text not null,
   filename_att_vmc     varchar(100),
   attachment_vmc       varchar(100),
   primary key (serial_vmc)
)
type = innodb;

/*==============================================================*/
/* Table: year_concept_taxes                                    */
/*==============================================================*/
create table year_concept_taxes
(
   serial_tax           int,
   value_yct            decimal(5,2),
   status_yct           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   serial_pct           int,
   serial_spt           int,
   serial_lvl           int,
   serial_scy           int,
   serial_set           int
)
type = innodb;

/*==============================================================*/
/* Table: year_grade_subject                                    */
/*==============================================================*/
create table year_grade_subject
(
   serial_ygs           int not null auto_increment,
   serial_scy           int,
   serial_csb           int,
   status_ygs           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_ygs)
)
type = innodb;

/*==============================================================*/
/* Table: year_level_specialty_payment_concept                  */
/*==============================================================*/
create table year_level_specialty_payment_concept
(
   serial_art           int,
   serial_pct           int not null,
   serial_spt           int not null,
   serial_lvl           int not null,
   serial_scy           int not null,
   serial_set           int not null,
   value_ypc            decimal(9,2) not null,
   frequency_ypc        enum('ANNUAL','MONTHLY') not null,
   repetitions_number_ypc int not null,
   enabling_concept_ypc enum('YES','NO') not null default 'NO',
   mandatory_ypc        enum('YES','NO') not null default 'NO',
   student_type_ypc     enum('NEW','OLD','BOTH') not null default 'BOTH',
   due_max_day_ypc      int not null,
   primary key (serial_pct, serial_spt, serial_lvl, serial_scy, serial_set)
)
type = innodb;

/*==============================================================*/
/* Table: year_qualifying_document                              */
/*==============================================================*/
create table year_qualifying_document
(
   serial_yqd           int not null auto_increment,
   serial_scy           int,
   serial_qdc           int,
   status_yqd           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_yqd)
)
type = innodb;

/*==============================================================*/
/* Table: year_resit_exam_ranges                                */
/*==============================================================*/
create table year_resit_exam_ranges
(
   serial_yre           int not null auto_increment,
   serial_scy           int,
   lower_limit_yre      decimal(5,2) not null,
   higher_limit_yre     decimal(5,2) not null,
   required_grade_yre   decimal(5,2) not null,
   status_yre           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_yre)
)
type = innodb;

/*==============================================================*/
/* Table: year_special_grade                                    */
/*==============================================================*/
create table year_special_grade
(
   serial_ysg           int not null auto_increment,
   serial_scy           int,
   name_ysg             varchar(256) not null,
   description_ysg      text not null,
   status_ysg           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_ysg)
)
type = innodb;

/*==============================================================*/
/* Table: year_subject_classroom                                */
/*==============================================================*/
create table year_subject_classroom
(
   serial_ysc           int not null auto_increment,
   serial_sbc           int,
   serial_clr           int,
   serial_osb           int,
   status_ysc           enum('ACTIVE','INACTIVE') not null default 'ACTIVE',
   primary key (serial_ysc)
)
type = innodb;

alter table access_log add constraint fk_relationship_143 foreign key (serial_usr, serial_prf)
      references user_profile (serial_usr, serial_prf) on delete restrict on update restrict;

alter table activity_applied_criterias add constraint fk_activity_header foreign key (serial_act)
      references activity (serial_act) on delete restrict on update restrict;

alter table activity_applied_criterias add constraint fk_relationship_95 foreign key (serial_att, serial_prd, serial_sbc, serial_sbj, serial_gct)
      references subject_year_activity_criteria_period (serial_att, serial_prd, serial_sbc, serial_sbj, serial_gct) on delete restrict on update restrict;

alter table activity_attachment add constraint fk_relationship_96 foreign key (serial_act)
      references activity (serial_act) on delete restrict on update restrict;

alter table activity_policy_violations add constraint fk_relationship_146 foreign key (serial_act)
      references activity (serial_act) on delete restrict on update restrict;

alter table activity_policy_violations add constraint fk_relationship_147 foreign key (serial_opa)
      references opt_activity (serial_opa) on delete restrict on update restrict;

alter table activity_policy_violations add constraint fk_relationship_148 foreign key (serial_emp)
      references employee (serial_emp) on delete restrict on update restrict;

alter table allowed_pages_by_process add constraint fk_child_pages foreign key (serial_prc)
      references process (serial_prc) on delete restrict on update restrict;

alter table authority add constraint fk_has_charge foreign key (serial_atc)
      references authority_charge (serial_atc) on delete restrict on update restrict;

alter table bus_shift_year add constraint fk_relationship_76 foreign key (serial_scy)
      references school_year (serial_scy) on delete restrict on update restrict;

alter table bus_shift_year add constraint fk_relationship_77 foreign key (serial_bdr)
      references bus_driver (serial_bdr) on delete restrict on update restrict;

alter table bus_shift_year add constraint fk_relationship_78 foreign key (serial_bus)
      references bus (serial_bus) on delete restrict on update restrict;

alter table bus_shift_year add constraint fk_relationship_79 foreign key (serial_rot)
      references route (serial_rot) on delete restrict on update restrict;

alter table bus_shift_year add constraint fk_relationship_80 foreign key (serial_sft)
      references shift (serial_sft) on delete restrict on update restrict;

alter table bus_shift_year add constraint fk_relationship_81 foreign key (bus_serial_bdr)
      references bus_driver (serial_bdr) on delete restrict on update restrict;

alter table bus_year_user add constraint fk_relationship_97 foreign key (serial_rot, serial_scy, serial_bus, serial_sft)
      references bus_shift_year (serial_rot, serial_scy, serial_bus, serial_sft) on delete restrict on update restrict;

alter table bus_year_user add constraint fk_relationship_98 foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table cat_subject add constraint fk_child_parent foreign key (cat_serial_csb)
      references cat_subject (serial_csb) on delete restrict on update restrict;

alter table cat_subject add constraint fk_relationship_62 foreign key (serial_aca)
      references academic_area (serial_aca) on delete restrict on update restrict;

alter table cat_subject add constraint fk_relationship_68 foreign key (serial_lng)
      references language (serial_lng) on delete restrict on update restrict;

alter table course add constraint fk_selected_class foreign key (serial_clg)
      references class_group (serial_clg) on delete restrict on update restrict;

alter table course add constraint fk_selected_level_speciality foreign key (serial_spt, serial_lvl, serial_scy, serial_set)
      references level_section_year_specialty (serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table course_director add constraint fk_relationship_144 foreign key (serial_emp)
      references employee (serial_emp) on delete restrict on update restrict;

alter table course_director add constraint fk_relationship_145 foreign key (serial_crs)
      references course (serial_crs) on delete restrict on update restrict;

alter table current_deferred add constraint fk_relationship_170 foreign key (serial_deb)
      references student_year_debts (serial_deb) on delete restrict on update restrict;

alter table discipline add constraint fk_relationship_130 foreign key (serial_std, serial_spt, serial_lvl, serial_scy, serial_set)
      references student_year (serial_std, serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table discipline add constraint fk_relationship_131 foreign key (serial_prd)
      references period (serial_prd) on delete restrict on update restrict;

alter table employee add constraint fk_employee_birth_country foreign key (serial_cou)
      references country (serial_cou) on delete restrict on update restrict;

alter table employee add constraint fk_employee_birth_state foreign key (serial_ste)
      references state (serial_ste) on delete restrict on update restrict;

alter table employee add constraint fk_employee_guardian2 foreign key (serial_grd)
      references guardian (serial_grd) on delete restrict on update restrict;

alter table employee add constraint fk_employee_user foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table employee add constraint fk_relationship_54 foreign key (serial_nnt)
      references nationality (serial_nnt) on delete restrict on update restrict;

alter table employee add constraint fk_relationship_55 foreign key (serial_tdg)
      references teacher_degree (serial_tdg) on delete restrict on update restrict;

alter table employee add constraint fk_relationship_56 foreign key (serial_tmd)
      references teacher_master_degree (serial_tmd) on delete restrict on update restrict;

alter table employee add constraint fk_relationship_57 foreign key (serial_tst)
      references teacher_specialty (serial_tst) on delete restrict on update restrict;

alter table employee add constraint fk_relationship_58 foreign key (serial_dgr)
      references degree (serial_dgr) on delete restrict on update restrict;

alter table employee add constraint fk_relationship_59 foreign key (serial_mdg)
      references master_degree (serial_mdg) on delete restrict on update restrict;

alter table employee add constraint fk_relationship_60 foreign key (serial_unv)
      references university (serial_unv) on delete restrict on update restrict;

alter table employee_area add constraint fk_area_by_employee foreign key (serial_aca)
      references academic_area (serial_aca) on delete restrict on update restrict;

alter table employee_area add constraint fk_employee_in_area foreign key (serial_emp)
      references employee (serial_emp) on delete restrict on update restrict;

alter table general_activity_attendees add constraint fk_relationship_139 foreign key (serial_scy)
      references school_year (serial_scy) on delete restrict on update restrict;

alter table general_activity_attendees add constraint fk_relationship_140 foreign key (serial_gac)
      references general_activity (serial_gac) on delete restrict on update restrict;

alter table general_discipline_log add constraint fk_relationship_151 foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table general_discipline_log add constraint fk_relationship_152 foreign key (serial_prd, serial_std, serial_spt, serial_lvl, serial_scy, serial_set)
      references discipline (serial_prd, serial_std, serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table general_discipline_log add constraint fk_relationship_153 foreign key (serial_chr)
      references change_reason (serial_chr) on delete restrict on update restrict;

alter table grade_change_log add constraint fk_relationship_123 foreign key (serial_sbc, serial_att, serial_prd, serial_gct, serial_act, serial_std, serial_crs)
      references student_criteria_grade (serial_sbc, serial_att, serial_prd, serial_gct, serial_act, serial_std, serial_crs) on delete restrict on update restrict;

alter table grade_change_log add constraint fk_relationship_124 foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table grade_change_log add constraint fk_relationship_150 foreign key (serial_chr)
      references change_reason (serial_chr) on delete restrict on update restrict;

alter table grade_subject_score add constraint fk_relationship_176 foreign key (serial_ygs)
      references year_grade_subject (serial_ygs) on delete restrict on update restrict;

alter table grade_subject_score add constraint fk_relationship_177 foreign key (serial_std, serial_spt, serial_lvl, serial_scy, serial_set)
      references student_year (serial_std, serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table group_hour_level add constraint fk_group_hour_for_level foreign key (serial_gph)
      references group_hour (serial_gph) on delete restrict on update restrict;

alter table group_hour_level add constraint fk_levels_in_group_hour foreign key (serial_lvl, serial_scy, serial_set)
      references level_section_year (serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table guardian add constraint fk_employee_guardian foreign key (serial_emp)
      references employee (serial_emp) on delete restrict on update restrict;

alter table guardian add constraint fk_guardian_user foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table hour_by_group add constraint fk_for_group foreign key (serial_gph)
      references group_hour (serial_gph) on delete restrict on update restrict;

alter table hour_by_group add constraint fk_is_in_group foreign key (serial_hrs)
      references hour (serial_hrs) on delete restrict on update restrict;

alter table incident add constraint fk_relationship_194 foreign key (use_serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table incident add constraint fk_relationship_195 foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table income_stock add constraint fk_relationship_184 foreign key (serial_prv)
      references provider (serial_prv) on delete restrict on update restrict;

alter table income_stock add constraint fk_relationship_185 foreign key (serial_mti)
      references maintenance_item (serial_mti) on delete restrict on update restrict;

alter table income_stock add constraint fk_relationship_186 foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table invoice_detail add constraint fk_relationship_155 foreign key (serial_phy)
      references invoice (serial_phy) on delete restrict on update restrict;

alter table invoice_detail add constraint fk_relationship_156 foreign key (serial_deb)
      references student_year_debts (serial_deb) on delete restrict on update restrict;

alter table invoice_detail add constraint fk_relationship_171 foreign key (serial_cdf)
      references current_deferred (serial_cdf) on delete restrict on update restrict;

alter table level_section_year add constraint fk_level_in_section foreign key (serial_lvl)
      references level (serial_lvl) on delete restrict on update restrict;

alter table level_section_year add constraint fk_period_group_level foreign key (serial_pgy)
      references period_group_year (serial_pgy) on delete restrict on update restrict;

alter table level_section_year add constraint fk_section_for_level foreign key (serial_scy, serial_set)
      references section_by_year (serial_scy, serial_set) on delete restrict on update restrict;

alter table level_section_year_specialty add constraint fk_selected_level foreign key (serial_lvl, serial_scy, serial_set)
      references level_section_year (serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table level_section_year_specialty add constraint fk_selected_specialty foreign key (serial_spt)
      references specialty (serial_spt) on delete restrict on update restrict;

alter table maintenance_item add constraint fk_relationship_183 foreign key (serial_ict)
      references item_category (serial_ict) on delete restrict on update restrict;

alter table medical_file add constraint fk_relationship_196 foreign key (serial_gst)
      references guest (serial_gst) on delete restrict on update restrict;

alter table medical_file add constraint fk_relationship_65 foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table message add constraint fk_relationship_136 foreign key (serial_usr_send)
      references user (serial_usr) on delete restrict on update restrict;

alter table message add constraint fk_relationship_137 foreign key (serial_usr_receive)
      references user (serial_usr) on delete restrict on update restrict;

alter table message add constraint fk_relationship_154 foreign key (serial_prf)
      references profile (serial_prf) on delete restrict on update restrict;

alter table message_between_profiles add constraint fk_relationship_141 foreign key (serial_prf)
      references profile (serial_prf) on delete restrict on update restrict;

alter table message_between_profiles add constraint fk_relationship_142 foreign key (pro_serial_prf)
      references profile (serial_prf) on delete restrict on update restrict;

alter table message_thread add constraint fk_relationship_138 foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table message_thread_messages add constraint fk_relationship_134 foreign key (serial_mth)
      references message_thread (serial_mth) on delete restrict on update restrict;

alter table message_thread_messages add constraint fk_relationship_135 foreign key (serial_msg)
      references message (serial_msg) on delete restrict on update restrict;

alter table optional_subject add constraint fk_relationship_116 foreign key (serial_pgy)
      references period_group_year (serial_pgy) on delete restrict on update restrict;

alter table optional_subject add constraint fk_relationship_127 foreign key (serial_aca, serial_emp)
      references employee_area (serial_aca, serial_emp) on delete restrict on update restrict;

alter table optional_subject add constraint fk_relationship_53 foreign key (serial_csb)
      references cat_subject (serial_csb) on delete restrict on update restrict;

alter table optional_subject_level add constraint fk_relationship_104 foreign key (serial_spt, serial_lvl, serial_scy, serial_set)
      references level_section_year_specialty (serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table optional_subject_level add constraint fk_relationship_105 foreign key (serial_osb)
      references optional_subject (serial_osb) on delete restrict on update restrict;

alter table optional_subject_period add constraint fk_relationship_106 foreign key (serial_osb)
      references optional_subject (serial_osb) on delete restrict on update restrict;

alter table optional_subject_period add constraint fk_relationship_107 foreign key (serial_prd)
      references period (serial_prd) on delete restrict on update restrict;

alter table optional_subject_retest add constraint fk_relationship_198 foreign key (serial_prd, serial_osb)
      references optional_subject_period (serial_prd, serial_osb) on delete restrict on update restrict;

alter table optional_subject_retest_student add constraint fk_relationship_199 foreign key (serial_osr)
      references optional_subject_retest (serial_osr) on delete restrict on update restrict;

alter table optional_subject_retest_student add constraint fk_relationship_200 foreign key (serial_std)
      references student (serial_std) on delete restrict on update restrict;

alter table opt_activity_applied_criterias add constraint fk_relationship_117 foreign key (serial_gct, serial_osb, serial_att, serial_prd)
      references opt_subject_year_activity_criteria_period (serial_gct, serial_osb, serial_att, serial_prd) on delete restrict on update restrict;

alter table opt_activity_applied_criterias add constraint fk_relationship_118 foreign key (serial_opa)
      references opt_activity (serial_opa) on delete restrict on update restrict;

alter table opt_activity_attachment add constraint fk_relationship_119 foreign key (serial_opa)
      references opt_activity (serial_opa) on delete restrict on update restrict;

alter table opt_grade_change_log add constraint fk_relationship_125 foreign key (serial_opa, serial_gct, serial_osb, serial_att, serial_prd, serial_std)
      references opt_student_criteria_grade (serial_opa, serial_gct, serial_osb, serial_att, serial_prd, serial_std) on delete restrict on update restrict;

alter table opt_grade_change_log add constraint fk_relationship_126 foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table opt_grade_change_log add constraint fk_relationship_149 foreign key (serial_chr)
      references change_reason (serial_chr) on delete restrict on update restrict;

/*alter table opt_student_activity_attachment add constraint fk_relationship_122 foreign key (serial_opa, serial_std)
      references opt_student_criteria_grade (serial_opa, serial_std) on delete restrict on update restrict;

alter table opt_student_criteria_grade add constraint fk_relationship_120 foreign key (serial_std)
      references student_optional_subject (serial_std) on delete restrict on update restrict;*/

alter table opt_student_criteria_grade add constraint fk_relationship_121 foreign key (serial_opa, serial_gct, serial_osb, serial_att, serial_prd)
      references opt_activity_applied_criterias (serial_opa, serial_gct, serial_osb, serial_att, serial_prd) on delete restrict on update restrict;

alter table opt_subject_period_activity_type add constraint fk_relationship_112 foreign key (serial_prd, serial_osb)
      references optional_subject_period (serial_prd, serial_osb) on delete restrict on update restrict;

alter table opt_subject_period_activity_type add constraint fk_relationship_113 foreign key (serial_att)
      references activity_type (serial_att) on delete restrict on update restrict;

alter table opt_subject_year_activity_criteria_period add constraint fk_relationship_114 foreign key (serial_att, serial_prd)
      references opt_subject_period_activity_type (serial_att, serial_prd) on delete restrict on update restrict;

alter table opt_subject_year_activity_criteria_period add constraint fk_relationship_115 foreign key (serial_gct, serial_osb)
      references opt_subject_year_grade_criteria (serial_gct, serial_osb) on delete restrict on update restrict;

alter table opt_subject_year_grade_criteria add constraint fk_relationship_110 foreign key (serial_osb)
      references optional_subject (serial_osb) on delete restrict on update restrict;

alter table opt_subject_year_grade_criteria add constraint fk_relationship_111 foreign key (serial_gct)
      references grade_criteria (serial_gct) on delete restrict on update restrict;

alter table payment_detail add constraint fk_relationship_172 foreign key (serial_phy)
      references invoice (serial_phy) on delete restrict on update restrict;

alter table payment_detail add constraint fk_relationship_173 foreign key (serial_pym)
      references payment_method (serial_pym) on delete restrict on update restrict;

alter table payment_detail add constraint fk_relationship_191 foreign key (serial_ccd)
      references credit_card (serial_ccd) on delete restrict on update restrict;

alter table payment_detail add constraint fk_relationship_192 foreign key (serial_fin)
      references financial_institution (serial_fin) on delete restrict on update restrict;

alter table period add constraint fk_periods_by_group foreign key (serial_pgy)
      references period_group_year (serial_pgy) on delete restrict on update restrict;

alter table period_group_year add constraint fk_periods_in_year foreign key (serial_scy)
      references school_year (serial_scy) on delete restrict on update restrict;

alter table period_group_year add constraint fk_period_for_year foreign key (serial_cpd)
      references cat_period (serial_cpd) on delete restrict on update restrict;

alter table pre_registration add constraint fk_registered_nationality foreign key (serial_nnt)
      references nationality (serial_nnt) on delete restrict on update restrict;

alter table pre_registration add constraint fk_relationship_64 foreign key (serial_spt, serial_lvl, serial_scy, serial_set)
      references level_section_year_specialty (serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table pre_registration add constraint fk_relationship_67 foreign key (serial_dgr)
      references degree (serial_dgr) on delete restrict on update restrict;

alter table pre_registration add constraint fk_user_register foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table pre_registration_period add constraint fk_relationship_73 foreign key (serial_scy)
      references school_year (serial_scy) on delete restrict on update restrict;

alter table process add constraint fk_parent_process foreign key (prc_serial_prc)
      references process (serial_prc) on delete restrict on update restrict;

alter table profile_process add constraint fk_has_process foreign key (serial_prf)
      references profile (serial_prf) on delete restrict on update restrict;

alter table profile_process add constraint fk_in_profile foreign key (serial_prc)
      references process (serial_prc) on delete restrict on update restrict;

alter table psychological_file add constraint fk_relationship_89 foreign key (serial_std)
      references student (serial_std) on delete restrict on update restrict;

alter table qualitative_equivalence add constraint fk_relationship_161 foreign key (serial_scy)
      references school_year (serial_scy) on delete restrict on update restrict;

alter table request_detail add constraint fk_relationship_188 foreign key (serial_ist)
      references income_stock (serial_ist) on delete restrict on update restrict;

alter table request_detail add constraint fk_relationship_189 foreign key (serial_srq)
      references stock_request (serial_srq) on delete restrict on update restrict;

alter table school_setup add constraint fk_currency_for_school foreign key (serial_crr)
      references currency (serial_crr) on delete restrict on update restrict;

alter table school_setup add constraint fk_school_state foreign key (serial_ste)
      references state (serial_ste) on delete restrict on update restrict;

alter table section_by_year add constraint fk_section_in_year foreign key (serial_set)
      references section (serial_set) on delete restrict on update restrict;

alter table section_by_year add constraint fk_year_sections foreign key (serial_scy)
      references school_year (serial_scy) on delete restrict on update restrict;

alter table state add constraint fk_country_state foreign key (serial_cou)
      references country (serial_cou) on delete restrict on update restrict;

alter table stock_request add constraint fk_relationship_187 foreign key (serial_udt)
      references use_destination (serial_udt) on delete restrict on update restrict;

alter table stock_request add constraint fk_relationship_190 foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table student add constraint fk_relationship_61 foreign key (serial_nnt)
      references nationality (serial_nnt) on delete restrict on update restrict;

alter table student add constraint fk_student_user foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

/*alter table student_activity_attachment add constraint fk_relationship_101 foreign key (serial_std, serial_act)
      references student_criteria_grade (serial_std, serial_act) on delete restrict on update restrict;*/

alter table student_by_course add constraint fk_course_for_student foreign key (serial_crs)
      references course (serial_crs) on delete restrict on update restrict;

alter table student_by_course add constraint fk_student_in_course foreign key (serial_std)
      references student (serial_std) on delete restrict on update restrict;

alter table student_criteria_grade add constraint fk_relationship_100 foreign key (serial_std, serial_crs)
      references student_by_course (serial_std, serial_crs) on delete restrict on update restrict;

alter table student_criteria_grade add constraint fk_relationship_99 foreign key (serial_att, serial_prd, serial_sbc, serial_gct, serial_act)
      references activity_applied_criterias (serial_att, serial_prd, serial_sbc, serial_gct, serial_act) on delete restrict on update restrict;

alter table student_guardian add constraint fk_has_guardian foreign key (serial_std)
      references student (serial_std) on delete restrict on update restrict;

alter table student_guardian add constraint fk_is_guardian foreign key (serial_grd)
      references guardian (serial_grd) on delete restrict on update restrict;

alter table student_optional_subject add constraint fk_relationship_108 foreign key (serial_osb)
      references optional_subject (serial_osb) on delete restrict on update restrict;

alter table student_optional_subject add constraint fk_relationship_109 foreign key (serial_std)
      references student (serial_std) on delete restrict on update restrict;

alter table student_year add constraint fk_relationship_74 foreign key (serial_std)
      references student (serial_std) on delete restrict on update restrict;

alter table student_year add constraint fk_relationship_75 foreign key (serial_spt, serial_lvl, serial_scy, serial_set)
      references level_section_year_specialty (serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table student_year_debts add constraint fk_relationship_102 foreign key (serial_pct, serial_spt, serial_lvl, serial_scy, serial_set)
      references year_level_specialty_payment_concept (serial_pct, serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table student_year_debts add constraint fk_relationship_103 foreign key (serial_std)
      references student (serial_std) on delete restrict on update restrict;

alter table student_year_document add constraint fk_relationship_159 foreign key (serial_std, serial_spt, serial_lvl, serial_scy, serial_set)
      references student_year (serial_std, serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table student_year_document add constraint fk_relationship_160 foreign key (serial_yqd)
      references year_qualifying_document (serial_yqd) on delete restrict on update restrict;

alter table student_year_special_grade add constraint fk_relationship_179 foreign key (serial_ysg)
      references year_special_grade (serial_ysg) on delete restrict on update restrict;

alter table student_year_special_grade add constraint fk_relationship_180 foreign key (serial_std, serial_spt, serial_lvl, serial_scy, serial_set)
      references student_year (serial_std, serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table subject add constraint fk_subject_fo__level foreign key (serial_spt, serial_lvl, serial_scy, serial_set)
      references level_section_year_specialty (serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table subject add constraint fk_year_subject foreign key (serial_csb)
      references cat_subject (serial_csb) on delete restrict on update restrict;

alter table subject_course add constraint fk_course_with_subject foreign key (serial_crs)
      references course (serial_crs) on delete restrict on update restrict;

alter table subject_course add constraint fk_is_teacher foreign key (serial_aca, serial_emp)
      references employee_area (serial_aca, serial_emp) on delete restrict on update restrict;

alter table subject_course add constraint fk_subject_for_course foreign key (serial_sbj)
      references subject (serial_sbj) on delete restrict on update restrict;

alter table subject_course_period add constraint fk_relationship_71 foreign key (serial_prd)
      references period (serial_prd) on delete restrict on update restrict;

alter table subject_course_period add constraint fk_relationship_72 foreign key (serial_sbc)
      references subject_course (serial_sbc) on delete restrict on update restrict;

alter table subject_course_retest add constraint fk_relationship_201 foreign key (serial_prd, serial_sbc)
      references subject_course_period (serial_prd, serial_sbc) on delete restrict on update restrict;

alter table subject_course_retest_student add constraint fk_relationship_202 foreign key (serial_scr)
      references subject_course_retest (serial_scr) on delete restrict on update restrict;

alter table subject_course_retest_student add constraint fk_relationship_203 foreign key (serial_std)
      references student (serial_std) on delete restrict on update restrict;

alter table subject_ministry_equivalence add constraint fk_relationship_166 foreign key (serial_msb)
      references ministry_subject (serial_msb) on delete restrict on update restrict;

alter table subject_ministry_equivalence add constraint fk_relationship_169 foreign key (serial_emp)
      references employee (serial_emp) on delete restrict on update restrict;

alter table subject_ministry_equivalence add constraint fk_relationship_193 foreign key (serial_csb)
      references cat_subject (serial_csb) on delete restrict on update restrict;

alter table subject_ministry_equivalence add constraint fk_relationship_204 foreign key (serial_spt, serial_lvl, serial_scy, serial_set)
      references level_section_year_specialty (serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table subject_period_activity_type add constraint fk_relationship_84 foreign key (serial_prd, serial_sbc)
      references subject_course_period (serial_prd, serial_sbc) on delete restrict on update restrict;

alter table subject_period_activity_type add constraint fk_relationship_85 foreign key (serial_att)
      references activity_type (serial_att) on delete restrict on update restrict;

alter table subject_year_activity_criteria_period add constraint fk_relationship_86 foreign key (serial_att, serial_prd, serial_sbc)
      references subject_period_activity_type (serial_att, serial_prd, serial_sbc) on delete restrict on update restrict;

alter table subject_year_activity_criteria_period add constraint fk_relationship_87 foreign key (serial_sbj, serial_gct)
      references subject_year_grade_criteria (serial_sbj, serial_gct) on delete restrict on update restrict;

alter table subject_year_grade_criteria add constraint fk_relationship_82 foreign key (serial_sbj)
      references subject (serial_sbj) on delete restrict on update restrict;

alter table subject_year_grade_criteria add constraint fk_relationship_83 foreign key (serial_gct)
      references grade_criteria (serial_gct) on delete restrict on update restrict;

alter table syllabus_files add constraint fk_relationship_128 foreign key (serial_osb)
      references optional_subject (serial_osb) on delete restrict on update restrict;

alter table syllabus_files add constraint fk_relationship_129 foreign key (serial_sbc)
      references subject_course (serial_sbc) on delete restrict on update restrict;

alter table syllabus_files_change_log add constraint fk_relationship_132 foreign key (serial_syf)
      references syllabus_files (serial_syf) on delete restrict on update restrict;

alter table syllabus_files_change_log add constraint fk_relationship_133 foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table teacher_hours_year add constraint fk_relationship_69 foreign key (serial_emp)
      references employee (serial_emp) on delete restrict on update restrict;

alter table teacher_hours_year add constraint fk_relationship_70 foreign key (serial_scy)
      references school_year (serial_scy) on delete restrict on update restrict;

alter table user add constraint fk_employee_user2 foreign key (serial_emp)
      references employee (serial_emp) on delete restrict on update restrict;

alter table user add constraint fk_guardian_user2 foreign key (serial_grd)
      references guardian (serial_grd) on delete restrict on update restrict;

alter table user add constraint fk_student_user2 foreign key (serial_std)
      references student (serial_std) on delete restrict on update restrict;

alter table user_profile add constraint fk_for_user foreign key (serial_prf)
      references profile (serial_prf) on delete restrict on update restrict;

alter table user_profile add constraint fk_has_profile foreign key (serial_usr)
      references user (serial_usr) on delete restrict on update restrict;

alter table visits_medical_center add constraint fk_relationship_197 foreign key (serial_mdf)
      references medical_file (serial_mdf) on delete restrict on update restrict;

alter table year_concept_taxes add constraint fk_relationship_93 foreign key (serial_tax)
      references taxes (serial_tax) on delete restrict on update restrict;

alter table year_concept_taxes add constraint fk_relationship_94 foreign key (serial_pct, serial_spt, serial_lvl, serial_scy, serial_set)
      references year_level_specialty_payment_concept (serial_pct, serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table year_grade_subject add constraint fk_relationship_174 foreign key (serial_csb)
      references cat_subject (serial_csb) on delete restrict on update restrict;

alter table year_grade_subject add constraint fk_relationship_175 foreign key (serial_scy)
      references school_year (serial_scy) on delete restrict on update restrict;

alter table year_level_specialty_payment_concept add constraint fk_relationship_90 foreign key (serial_spt, serial_lvl, serial_scy, serial_set)
      references level_section_year_specialty (serial_spt, serial_lvl, serial_scy, serial_set) on delete restrict on update restrict;

alter table year_level_specialty_payment_concept add constraint fk_relationship_91 foreign key (serial_pct)
      references payment_concept (serial_pct) on delete restrict on update restrict;

alter table year_level_specialty_payment_concept add constraint fk_relationship_92 foreign key (serial_art)
      references article (serial_art) on delete restrict on update restrict;

alter table year_qualifying_document add constraint fk_relationship_157 foreign key (serial_scy)
      references school_year (serial_scy) on delete restrict on update restrict;

alter table year_qualifying_document add constraint fk_relationship_158 foreign key (serial_qdc)
      references qualifying_document (serial_qdc) on delete restrict on update restrict;

alter table year_resit_exam_ranges add constraint fk_relationship_162 foreign key (serial_scy)
      references school_year (serial_scy) on delete restrict on update restrict;

alter table year_special_grade add constraint fk_relationship_178 foreign key (serial_scy)
      references school_year (serial_scy) on delete restrict on update restrict;

alter table year_subject_classroom add constraint fk_relationship_163 foreign key (serial_clr)
      references classroom (serial_clr) on delete restrict on update restrict;

alter table year_subject_classroom add constraint fk_relationship_164 foreign key (serial_sbc)
      references subject_course (serial_sbc) on delete restrict on update restrict;

alter table year_subject_classroom add constraint fk_relationship_165 foreign key (serial_osb)
      references optional_subject (serial_osb) on delete restrict on update restrict;

