Files
hzdyjs/docs/设计文档/database/学工管理-学生信息管理/21-create-college-major-simple.sql
T
2025-07-19 10:18:27 +08:00

254 lines
13 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- ==========================================
-- 学院和专业信息表创建脚本(简化版)
-- 版本:V1.0.0
-- 创建时间:2025-01-22
-- 说明:创建xg_college_info和xg_major_info表
-- 使用方法:在数据库管理工具中执行此脚本
-- ==========================================
USE hzdyjs_xg;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ===========================================
-- 1. 创建学院信息表
-- ===========================================
DROP TABLE IF EXISTS `xg_college_info`;
CREATE TABLE `xg_college_info` (
`id` bigint(20) NOT NULL COMMENT '主键ID',
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
`create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
-- 学院基础信息
`college_code` varchar(20) NOT NULL COMMENT '学院代码',
`college_name` varchar(100) NOT NULL COMMENT '学院名称',
`college_short_name` varchar(50) DEFAULT NULL COMMENT '学院简称',
`college_type` varchar(20) DEFAULT 'normal' COMMENT '学院类型',
`college_status` char(1) DEFAULT '1' COMMENT '学院状态:1-正常,2-停用',
`establish_date` date DEFAULT NULL COMMENT '成立日期',
-- 联系信息
`contact_person` varchar(50) DEFAULT NULL COMMENT '联系人',
`contact_phone` varchar(20) DEFAULT NULL COMMENT '联系电话',
`contact_email` varchar(100) DEFAULT NULL COMMENT '联系邮箱',
`office_location` varchar(200) DEFAULT NULL COMMENT '办公地点',
-- 管理信息
`dean_name` varchar(50) DEFAULT NULL COMMENT '院长姓名',
`secretary_name` varchar(50) DEFAULT NULL COMMENT '党委书记姓名',
-- 统计信息
`student_count` int(11) DEFAULT 0 COMMENT '学生总数',
`teacher_count` int(11) DEFAULT 0 COMMENT '教师总数',
`major_count` int(11) DEFAULT 0 COMMENT '专业总数',
`class_count` int(11) DEFAULT 0 COMMENT '班级总数',
-- 其他信息
`college_description` text DEFAULT NULL COMMENT '学院简介',
`sort_order` int(11) DEFAULT 0 COMMENT '排序顺序',
`remark` varchar(500) DEFAULT NULL COMMENT '备注信息',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_college_code_tenant` (`college_code`, `tenant_id`, `deleted`),
KEY `idx_tenant_id` (`tenant_id`),
KEY `idx_deleted` (`deleted`),
KEY `idx_college_status` (`college_status`),
KEY `idx_sort_order` (`sort_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='学院信息表';
-- ===========================================
-- 2. 创建专业信息表
-- ===========================================
DROP TABLE IF EXISTS `xg_major_info`;
CREATE TABLE `xg_major_info` (
`id` bigint(20) NOT NULL COMMENT '主键ID',
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
`create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
-- 专业基础信息
`major_code` varchar(20) NOT NULL COMMENT '专业代码',
`major_name` varchar(100) NOT NULL COMMENT '专业名称',
`major_short_name` varchar(50) DEFAULT NULL COMMENT '专业简称',
`major_category` varchar(50) DEFAULT NULL COMMENT '专业大类',
`major_type` varchar(20) DEFAULT 'undergraduate' COMMENT '专业类型:undergraduate-本科,graduate-研究生,vocational-专科',
`discipline_code` varchar(20) DEFAULT NULL COMMENT '学科门类代码',
`discipline_name` varchar(100) DEFAULT NULL COMMENT '学科门类名称',
-- 所属学院
`college_id` bigint(20) NOT NULL COMMENT '所属学院ID',
`college_code` varchar(20) NOT NULL COMMENT '所属学院代码',
`college_name` varchar(100) NOT NULL COMMENT '所属学院名称',
-- 专业状态
`major_status` char(1) DEFAULT '1' COMMENT '专业状态:1-正常,2-停招,3-撤销',
`establish_date` date DEFAULT NULL COMMENT '设立日期',
`first_enrollment_year` int(4) DEFAULT NULL COMMENT '首次招生年份',
-- 培养信息
`training_type` varchar(20) DEFAULT '全日制' COMMENT '培养方式',
`degree_type` varchar(20) DEFAULT '本科' COMMENT '学位类型',
`school_system` int(2) DEFAULT 4 COMMENT '学制(年)',
`credit_requirement` int(3) DEFAULT 0 COMMENT '学分要求',
-- 招生信息
`enrollment_plan` int(11) DEFAULT 0 COMMENT '年度招生计划',
`current_enrollment` int(11) DEFAULT 0 COMMENT '当前在校生数',
`total_enrollment` int(11) DEFAULT 0 COMMENT '历年累计招生数',
`graduate_count` int(11) DEFAULT 0 COMMENT '毕业生总数',
-- 师资信息
`teacher_count` int(11) DEFAULT 0 COMMENT '专任教师数',
`professor_count` int(11) DEFAULT 0 COMMENT '教授数',
`associate_professor_count` int(11) DEFAULT 0 COMMENT '副教授数',
-- 负责人信息
`director_name` varchar(50) DEFAULT NULL COMMENT '专业负责人姓名',
`contact_person` varchar(50) DEFAULT NULL COMMENT '联系人',
`contact_phone` varchar(20) DEFAULT NULL COMMENT '联系电话',
`contact_email` varchar(100) DEFAULT NULL COMMENT '联系邮箱',
-- 专业特色
`major_features` text DEFAULT NULL COMMENT '专业特色',
`training_objectives` text DEFAULT NULL COMMENT '培养目标',
`core_courses` text DEFAULT NULL COMMENT '核心课程',
-- 就业信息
`employment_rate` decimal(5,2) DEFAULT 0.00 COMMENT '就业率(%)',
`graduate_school_rate` decimal(5,2) DEFAULT 0.00 COMMENT '升学率(%)',
`salary_average` decimal(10,2) DEFAULT 0.00 COMMENT '平均薪资',
-- 其他信息
`sort_order` int(11) DEFAULT 0 COMMENT '排序顺序',
`is_key_major` tinyint(1) DEFAULT 0 COMMENT '是否重点专业',
`remark` varchar(500) DEFAULT NULL COMMENT '备注信息',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_major_code_tenant` (`major_code`, `tenant_id`, `deleted`),
KEY `idx_tenant_id` (`tenant_id`),
KEY `idx_deleted` (`deleted`),
KEY `idx_college_id` (`college_id`),
KEY `idx_college_code` (`college_code`),
KEY `idx_major_status` (`major_status`),
KEY `idx_major_type` (`major_type`),
KEY `idx_sort_order` (`sort_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='专业信息表';
-- ===========================================
-- 3. 插入学院基础数据
-- ===========================================
INSERT INTO `xg_college_info` (
`id`, `tenant_id`, `college_code`, `college_name`, `college_short_name`,
`college_type`, `college_status`, `establish_date`, `contact_phone`,
`office_location`, `sort_order`, `college_description`,
`create_by`, `create_time`, `update_by`, `update_time`
) VALUES
(1100001, '000000', 'CS', '计算机科学与技术学院', '计算机学院', 'normal', '1', '2000-01-01', '0571-88000001', '教学楼A座', 1, '培养计算机科学与技术专业人才', 1, NOW(), 1, NOW()),
(1100002, '000000', 'EE', '电子信息工程学院', '电信学院', 'normal', '1', '2000-01-01', '0571-88000002', '教学楼B座', 2, '培养电子信息工程专业人才', 1, NOW(), 1, NOW()),
(1100003, '000000', 'ME', '机械工程学院', '机械学院', 'normal', '1', '2000-01-01', '0571-88000003', '教学楼C座', 3, '培养机械工程专业人才', 1, NOW(), 1, NOW()),
(1100004, '000000', 'EC', '经济管理学院', '经管学院', 'normal', '1', '2000-01-01', '0571-88000004', '教学楼D座', 4, '培养经济管理专业人才', 1, NOW(), 1, NOW()),
(1100005, '000000', 'LA', '文理学院', '文理学院', 'normal', '1', '2000-01-01', '0571-88000005', '教学楼E座', 5, '培养文理科专业人才', 1, NOW(), 1, NOW());
-- ===========================================
-- 4. 插入专业基础数据
-- ===========================================
INSERT INTO `xg_major_info` (
`id`, `tenant_id`, `major_code`, `major_name`, `major_short_name`,
`major_category`, `major_type`, `college_id`, `college_code`, `college_name`,
`major_status`, `establish_date`, `first_enrollment_year`, `training_type`,
`degree_type`, `school_system`, `enrollment_plan`, `sort_order`,
`training_objectives`, `create_by`, `create_time`, `update_by`, `update_time`
) VALUES
-- 计算机科学与技术学院专业
(1200001, '000000', 'CS001', '计算机科学与技术', '计算机', '工学', 'undergraduate', 1100001, 'CS', '计算机科学与技术学院', '1', '2000-01-01', 2000, '全日制', '本科', 4, 100, 1, '培养计算机科学与技术专业人才', 1, NOW(), 1, NOW()),
(1200002, '000000', 'CS002', '软件工程', '软件工程', '工学', 'undergraduate', 1100001, 'CS', '计算机科学与技术学院', '1', '2005-01-01', 2005, '全日制', '本科', 4, 80, 2, '培养软件工程专业人才', 1, NOW(), 1, NOW()),
(1200003, '000000', 'CS003', '网络工程', '网络工程', '工学', 'undergraduate', 1100001, 'CS', '计算机科学与技术学院', '1', '2008-01-01', 2008, '全日制', '本科', 4, 60, 3, '培养网络工程专业人才', 1, NOW(), 1, NOW()),
-- 电子信息工程学院专业
(1200004, '000000', 'EE001', '电子信息工程', '电信工程', '工学', 'undergraduate', 1100002, 'EE', '电子信息工程学院', '1', '2000-01-01', 2000, '全日制', '本科', 4, 90, 1, '培养电子信息工程专业人才', 1, NOW(), 1, NOW()),
(1200005, '000000', 'EE002', '通信工程', '通信工程', '工学', 'undergraduate', 1100002, 'EE', '电子信息工程学院', '1', '2002-01-01', 2002, '全日制', '本科', 4, 70, 2, '培养通信工程专业人才', 1, NOW(), 1, NOW()),
(1200006, '000000', 'EE003', '自动化', '自动化', '工学', 'undergraduate', 1100002, 'EE', '电子信息工程学院', '1', '2003-01-01', 2003, '全日制', '本科', 4, 80, 3, '培养自动化专业人才', 1, NOW(), 1, NOW()),
-- 机械工程学院专业
(1200007, '000000', 'ME001', '机械设计制造及其自动化', '机械设计', '工学', 'undergraduate', 1100003, 'ME', '机械工程学院', '1', '2000-01-01', 2000, '全日制', '本科', 4, 100, 1, '培养机械设计制造专业人才', 1, NOW(), 1, NOW()),
(1200008, '000000', 'ME002', '机械电子工程', '机电工程', '工学', 'undergraduate', 1100003, 'ME', '机械工程学院', '1', '2004-01-01', 2004, '全日制', '本科', 4, 60, 2, '培养机械电子工程专业人才', 1, NOW(), 1, NOW()),
-- 经济管理学院专业
(1200009, '000000', 'EC001', '工商管理', '工商管理', '管理学', 'undergraduate', 1100004, 'EC', '经济管理学院', '1', '2000-01-01', 2000, '全日制', '本科', 4, 80, 1, '培养工商管理专业人才', 1, NOW(), 1, NOW()),
(1200010, '000000', 'EC002', '会计学', '会计学', '管理学', 'undergraduate', 1100004, 'EC', '经济管理学院', '1', '2001-01-01', 2001, '全日制', '本科', 4, 90, 2, '培养会计学专业人才', 1, NOW(), 1, NOW()),
-- 文理学院专业
(1200011, '000000', 'LA001', '汉语言文学', '中文', '文学', 'undergraduate', 1100005, 'LA', '文理学院', '1', '2000-01-01', 2000, '全日制', '本科', 4, 50, 1, '培养汉语言文学专业人才', 1, NOW(), 1, NOW()),
(1200012, '000000', 'LA002', '英语', '英语', '文学', 'undergraduate', 1100005, 'LA', '文理学院', '1', '2000-01-01', 2000, '全日制', '本科', 4, 60, 2, '培养英语专业人才', 1, NOW(), 1, NOW());
-- ===========================================
-- 5. 创建查询视图
-- ===========================================
-- 学院选项视图
CREATE OR REPLACE VIEW v_college_options AS
SELECT
college_code as value,
college_name as label,
college_short_name,
college_status,
sort_order
FROM xg_college_info
WHERE deleted = 0 AND college_status = '1'
ORDER BY sort_order, college_name;
-- 专业选项视图
CREATE OR REPLACE VIEW v_major_options AS
SELECT
m.major_code as value,
m.major_name as label,
m.major_short_name,
m.college_code,
m.college_name,
m.major_type,
m.major_status,
m.sort_order
FROM xg_major_info m
WHERE m.deleted = 0 AND m.major_status = '1'
ORDER BY m.college_code, m.sort_order, m.major_name;
-- 学院专业关联视图
CREATE OR REPLACE VIEW v_college_major_relation AS
SELECT
c.id as college_id,
c.college_code,
c.college_name,
m.id as major_id,
m.major_code,
m.major_name,
m.major_type,
m.school_system,
m.enrollment_plan
FROM xg_college_info c
LEFT JOIN xg_major_info m ON c.id = m.college_id
WHERE c.deleted = 0 AND c.college_status = '1'
AND (m.deleted = 0 AND m.major_status = '1' OR m.id IS NULL)
ORDER BY c.sort_order, m.sort_order;
-- 恢复外键检查
SET FOREIGN_KEY_CHECKS = 1;
-- ===========================================
-- 执行完成提示
-- ===========================================
SELECT '学院信息表和专业信息表创建完成!' as message;
SELECT '已插入5个学院和12个专业的基础数据' as info;
SELECT '可以通过以下视图查询数据:' as views;
SELECT 'v_college_options - 学院选项' as view1;
SELECT 'v_major_options - 专业选项' as view2;
SELECT 'v_college_major_relation - 学院专业关联' as view3;