PHP做web排课系统如何设计数据库及自动排课?

PHP做web排课系统如何设计数据库及自动排课?,第1张

PHP做web排课系统

1、在排课系统中我们首先要确定一学期的科目数、每一科目的课程数,再根据所有科目的课程数确定总课程数、每天的最大课程数。

2、选一个科目,在排课中可以设置一个随机数,如时间,然后取其中的七位数字,根据七位数字的大小顺序来确定每天的课程按排的顺序号,如3251643,则第一天上第三节课、第二天上第2节课、第三天上第5节课,如此类推;并记录下已经使用的位置,在下一轮的排序中不能再使用

刚用powerdesigner做了一个不是很完整,如有帮助最好

/*==============================================================*/

/* DBMS name: Microsoft SQL Server 2005*/

/* Created on: 2008-5-16 21:05:41 */

/*==============================================================*/

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('Class_Time_Map') and o.name = 'FK_CLASS_TI_REFERENCE_上课时段')

alter table Class_Time_Map

drop constraint FK_CLASS_TI_REFERENCE_上课时段

go

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('Class_Time_Map') and o.name = 'FK_CLASS_TI_REFERENCE_班级')

alter table Class_Time_Map

drop constraint FK_CLASS_TI_REFERENCE_班级

go

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('Room_Time_Map') and o.name = 'FK_ROOM_TIM_REFERENCE_上课时段')

alter table Room_Time_Map

drop constraint FK_ROOM_TIM_REFERENCE_上课时段

go

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('Room_Time_Map') and o.name = 'FK_ROOM_TIM_REFERENCE_教室表')

alter table Room_Time_Map

drop constraint FK_ROOM_TIM_REFERENCE_教室表

go

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('Teacher_Time_Map') and o.name = 'FK_TEACHER__REFERENCE_教师')

alter table Teacher_Time_Map

drop constraint FK_TEACHER__REFERENCE_教师

go

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('Teacher_Time_Map') and o.name = 'FK_TEACHER__REFERENCE_上课时段')

alter table Teacher_Time_Map

drop constraint FK_TEACHER__REFERENCE_上课时段

go

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('教师课程对应表') and o.name = 'FK_教师课程对应表_REFERENCE_教师')

alter table 教师课程对应表

drop constraint FK_教师课程对应表_REFERENCE_教师

go

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('教师课程对应表') and o.name = 'FK_教师课程对应表_REFERENCE_课程')

alter table 教师课程对应表

drop constraint FK_教师课程对应表_REFERENCE_课程

go

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('班级课程对应表') and o.name = 'FK_班级课程对应表_REFERENCE_课程')

alter table 班级课程对应表

drop constraint FK_班级课程对应表_REFERENCE_课程

go

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('班级课程对应表') and o.name = 'FK_班级课程对应表_REFERENCE_班级')

alter table 班级课程对应表

drop constraint FK_班级课程对应表_REFERENCE_班级

go

if exists (select 1

from sysobjects

where id = object_id('Class_Time_Map')

and type = 'U')

drop table Class_Time_Map

go

if exists (select 1

from sysobjects

where id = object_id('Room_Time_Map')

and type = 'U')

drop table Room_Time_Map

go

if exists (select 1

from sysobjects

where id = object_id('Teacher_Time_Map')

and type = 'U')

drop table Teacher_Time_Map

go

if exists (select 1

from sysobjects

where id = object_id('上课时段')

and type = 'U')

drop table 上课时段

go

if exists (select 1

from sysobjects

where id = object_id('教室表')

and type = 'U')

drop table 教室表

go

if exists (select 1

from sysobjects

where id = object_id('教师')

and type = 'U')

drop table 教师

go

if exists (select 1

from sysobjects

where id = object_id('教师课程对应表')

and type = 'U')

drop table 教师课程对应表

go

if exists (select 1

from sysobjects

where id = object_id('班级')

and type = 'U')

drop table 班级

go

if exists (select 1

from sysobjects

where id = object_id('班级课程对应表')

and type = 'U')

drop table 班级课程对应表

go

if exists (select 1

from sysobjects

where id = object_id('课程')

and type = 'U')

drop table 课程

go

/*==============================================================*/

/* Table: Class_Time_Map*/

/*==============================================================*/

create table Class_Time_Map (

TimeID int not null,

班级ID int not null,

constraint PK_CLASS_TIME_MAP primary key (TimeID, 班级ID)

)

go

/*==============================================================*/

/* Table: Room_Time_Map */

/*==============================================================*/

create table Room_Time_Map (

教室ID int not null,

TimeID int not null,

constraint PK_ROOM_TIME_MAP primary key (教室ID, TimeID)

)

go

/*==============================================================*/

/* Table: Teacher_Time_Map */

/*==============================================================*/

create table Teacher_Time_Map (

教师ID int not null,

TimeID int not null,

constraint PK_TEACHER_TIME_MAP primary key (教师ID, TimeID)

)

go

/*==============================================================*/

/* Table: 上课时段 */

/*==============================================================*/

create table 上课时段 (

TimeID int not null,

Day int null,

Time int null,

constraint PK_上课时段 primary key (TimeID)

)

go

/*==============================================================*/

/* Table: 教室表 */

/*==============================================================*/

create table 教室表 (

教室ID int not null,

constraint PK_教室表 primary key (教室ID)

)

go

/*==============================================================*/

/* Table: 教师*/

/*==============================================================*/

create table 教师 (

教师ID int not null,

教师姓名 char (10)null,

constraint PK_教师 primary key (教师ID)

)

go

/*==============================================================*/

/* Table: 教师课程对应表 */

/*==============================================================*/

create table 教师课程对应表 (

教师ID int not null,

课程ID int not null,

constraint PK_教师课程对应表 primary key (教师ID, 课程ID)

)

go

/*==============================================================*/

/* Table: 班级*/

/*==============================================================*/

create table 班级 (

班级ID int not null,

专业 varchar(20) null,

constraint PK_班级 primary key (班级ID)

)

go

/*==============================================================*/

/* Table: 班级课程对应表 */

/*==============================================================*/

create table 班级课程对应表 (

课程ID int not null,

班级ID int not null,

constraint PK_班级课程对应表 primary key (课程ID, 班级ID)

)

go

/*==============================================================*/

/* Table: 课程*/

/*==============================================================*/

create table 课程 (

课程ID int not null,

课程名 varchar(Max) null,

Column_3 varchar(20) null,

constraint PK_课程 primary key (课程ID)

)

go

alter table Class_Time_Map

add constraint FK_CLASS_TI_REFERENCE_上课时段 foreign key (TimeID)

references 上课时段 (TimeID)

go

alter table Class_Time_Map

add constraint FK_CLASS_TI_REFERENCE_班级 foreign key (班级ID)

references 班级 (班级ID)

go

alter table Room_Time_Map

add constraint FK_ROOM_TIM_REFERENCE_上课时段 foreign key (TimeID)

references 上课时段 (TimeID)

go

alter table Room_Time_Map

add constraint FK_ROOM_TIM_REFERENCE_教室表 foreign key (教室ID)

references 教室表 (教室ID)

go

alter table Teacher_Time_Map

add constraint FK_TEACHER__REFERENCE_教师 foreign key (教师ID)

references 教师 (教师ID)

go

alter table Teacher_Time_Map

add constraint FK_TEACHER__REFERENCE_上课时段 foreign key (TimeID)

references 上课时段 (TimeID)

go

alter table 教师课程对应表

add constraint FK_教师课程对应表_REFERENCE_教师 foreign key (教师ID)

references 教师 (教师ID)

go

alter table 教师课程对应表

add constraint FK_教师课程对应表_REFERENCE_课程 foreign key (课程ID)

references 课程 (课程ID)

go

alter table 班级课程对应表

add constraint FK_班级课程对应表_REFERENCE_课程 foreign key (课程ID)

references 课程 (课程ID)

go

alter table 班级课程对应表

add constraint FK_班级课程对应表_REFERENCE_班级 foreign key (班级ID)

references 班级 (班级ID)

go


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/6682955.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-26
下一篇 2023-03-26

发表评论

登录后才能评论

评论列表(0条)

保存