-- --------------------------------------------------
-- Generated by Enterprise Architect Version 9.2.921
-- Created On : 星期一, 06 六月, 2016
-- DBMS : Oracle
-- --------------------------------------------------
-- Create Tables
CREATE TABLE CSTL_ASM_CLASS
(
CLS_ID NUMBER(18) NOT NULL, -- 主键
LEG_ID NUMBER(18) NOT NULL, -- 关联的航节ID
DECK VARCHAR2(1) NOT NULL, -- 甲板编号,U/M/L,默认L
CLASS VARCHAR2(1) NOT NULL, -- 舱位代码
SUB_CLASS VARCHAR2(30) NOT NULL, -- 子舱代码集合
CLASS_SEQ NUMBER(2) NOT NULL, -- 舱位排序
AISLE_NUMBER VARCHAR2(30) NOT NULL -- 舱位内部列布局信息
)
TABLESPACE SEAT_CSTL_DAT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 10M
next 1M
minextents 1
maxextents unlimited
)
;
COMMENT ON TABLE CSTL_ASM_CLASS IS ‘航班座位图舱位信息表‘
;
COMMENT ON COLUMN CSTL_ASM_CLASS.CLS_ID IS ‘主键‘
;
COMMENT ON COLUMN CSTL_ASM_CLASS.LEG_ID IS ‘关联的航节ID‘
;
COMMENT ON COLUMN CSTL_ASM_CLASS.DECK IS ‘甲板编号,U/M/L,默认L‘
;
COMMENT ON COLUMN CSTL_ASM_CLASS.CLASS IS ‘舱位代码‘
;
COMMENT ON COLUMN CSTL_ASM_CLASS.SUB_CLASS IS ‘子舱代码集合‘
;
COMMENT ON COLUMN CSTL_ASM_CLASS.CLASS_SEQ IS ‘舱位排序‘
;
COMMENT ON COLUMN CSTL_ASM_CLASS.AISLE_NUMBER IS ‘舱位内部列布局信息‘
;
CREATE TABLE CSTL_ASM_DOLLAR_LEG
(
LEG_ID NUMBER(18) NOT NULL, -- 对应航节表主键,是一个非真实的外键,作为本表的主键
HASH NUMBER(6) NOT NULL, -- 航班标识的HASH值,航班标识形如(CA1234T_10MAR16)
COUNT NUMBER(2) NOT NULL, -- 累计执行减$属性的次数
DE_TIME DATE NOT NULL, -- 减$的时间,此处时间应为UTC时间
CMD_HEAD VARCHAR2(100) NOT NULL, -- 减$时候的指令头部
SEAT VARCHAR2(4000), -- 减$的座位ID,以#分隔每一个座位。
CHECK_STATUS NUMBER(1) NOT NULL -- 标识航节自动上$属性后的复核状态,1标识没有复核,0标识复核过。
)
TABLESPACE SEAT_CSTL_DAT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 10M
next 1M
minextents 1
maxextents unlimited
)
;
COMMENT ON TABLE CSTL_ASM_DOLLAR_LEG IS ‘已被自动上$属性的航班的航节信息,用于起飞前某时刻减去$属性。‘
;
COMMENT ON COLUMN CSTL_ASM_DOLLAR_LEG.LEG_ID IS ‘对应航节表主键,是一个非真实的外键,作为本表的主键‘
;
COMMENT ON COLUMN CSTL_ASM_DOLLAR_LEG.HASH IS ‘航班标识的HASH值,航班标识形如(CA1234T_10MAR16)‘
;
COMMENT ON COLUMN CSTL_ASM_DOLLAR_LEG.COUNT IS ‘累计执行减$属性的次数‘
;
COMMENT ON COLUMN CSTL_ASM_DOLLAR_LEG.DE_TIME IS ‘减$的时间,此处时间应为UTC时间‘
;
COMMENT ON COLUMN CSTL_ASM_DOLLAR_LEG.CMD_HEAD IS ‘减$时候的指令头部‘
;
COMMENT ON COLUMN CSTL_ASM_DOLLAR_LEG.SEAT IS ‘减$的座位ID,以#分隔每一个座位。‘
;
COMMENT ON COLUMN CSTL_ASM_DOLLAR_LEG.CHECK_STATUS IS ‘标识航节自动上$属性后的复核状态,1标识没有复核,0标识复核过。‘
;
CREATE TABLE CSTL_ASM_FLIGHT
(
FLT_ID NUMBER(18) NOT NULL, -- 主键,唯一标识
AIRLINE VARCHAR2(2) NOT NULL, -- 航空公司
FLIGHT_NUMBER VARCHAR2(5) NOT NULL, -- 航班号,包含后缀
FLIGHT_DATE DATE NOT NULL, -- 起飞航班天,精确到日
ITINERARY VARCHAR2(70) NOT NULL, -- 航班的航程,A-B-C-D形式,最多支持16个航节,17个航站
STATUS NUMBER(10) NOT NULL, -- 航班状态
CONTEXT NUMBER(1) NOT NULL, -- 航班初始化上下文状态。1-发生IF;2-发生PNL;3-1和2都发生;0-其他
CREATE_TIME DATE NOT NULL, -- 本条记录首次创建时间
UPDATE_TIME DATE NOT NULL -- 航班被更新时间,精确到秒,多用于状态更新
)
TABLESPACE SEAT_CSTL_DAT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 10M
next 1M
minextents 1
maxextents unlimited
)
;
COMMENT ON TABLE CSTL_ASM_FLIGHT IS ‘航班信息总表‘
;
COMMENT ON COLUMN CSTL_ASM_FLIGHT.FLT_ID IS ‘主键,唯一标识‘
;
COMMENT ON COLUMN CSTL_ASM_FLIGHT.AIRLINE IS ‘航空公司‘
;
COMMENT ON COLUMN CSTL_ASM_FLIGHT.FLIGHT_NUMBER IS ‘航班号,包含后缀‘
;
COMMENT ON COLUMN CSTL_ASM_FLIGHT.FLIGHT_DATE IS ‘起飞航班天,精确到日‘
;
COMMENT ON COLUMN CSTL_ASM_FLIGHT.ITINERARY IS ‘航班的航程,A-B-C-D形式,最多支持16个航节,17个航站‘
;
COMMENT ON COLUMN CSTL_ASM_FLIGHT.STATUS IS ‘航班状态‘
;
COMMENT ON COLUMN CSTL_ASM_FLIGHT.CONTEXT IS ‘航班初始化上下文状态。1-发生IF;2-发生PNL;3-1和2都发生;0-其他‘
;
COMMENT ON COLUMN CSTL_ASM_FLIGHT.CREATE_TIME IS ‘本条记录首次创建时间‘
;
COMMENT ON COLUMN CSTL_ASM_FLIGHT.UPDATE_TIME IS ‘航班被更新时间,精确到秒,多用于状态更新‘
;
CREATE TABLE CSTL_ASM_LEG
(
LEG_ID NUMBER(18) NOT NULL, -- 主键,航节信息
FLT_ID NUMBER(18) NOT NULL, -- 关联FLIGHT表,外键功能,但非实际外键
EQT_TYPE VARCHAR2(3) NOT NULL, -- 机型
EQT_VERSION VARCHAR2(4) NOT NULL, -- 版本号
DEP_AIRPORT VARCHAR2(3) NOT NULL, -- 起飞机场
ARR_AIRPORT VARCHAR2(3) NOT NULL, -- 到达机场
LEG_SEQ NUMBER(2) NOT NULL, -- 航节在航程中的次序
STATUS NUMBER(10) NOT NULL, -- 航段状态
CONTEXT NUMBER(2) NOT NULL, -- 换飞机上下文状态,AEC,REA,SEA,PO分别对应四个bit
DEP_TIME DATE, -- 航段实际起飞时间
PLAN_DEP_TIME DATE -- 航段计划起飞时间
)
TABLESPACE SEAT_CSTL_DAT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 10M
next 1M
minextents 1
maxextents unlimited
)
;
COMMENT ON TABLE CSTL_ASM_LEG IS ‘航班座位图航节表‘
;
COMMENT ON COLUMN CSTL_ASM_LEG.LEG_ID IS ‘主键,航节信息‘
;
COMMENT ON COLUMN CSTL_ASM_LEG.FLT_ID IS ‘关联FLIGHT表,外键功能,但非实际外键‘
;
COMMENT ON COLUMN CSTL_ASM_LEG.EQT_TYPE IS ‘机型‘
;
COMMENT ON COLUMN CSTL_ASM_LEG.EQT_VERSION IS ‘版本号‘
;
COMMENT ON COLUMN CSTL_ASM_LEG.DEP_AIRPORT IS ‘起飞机场‘
;
COMMENT ON COLUMN CSTL_ASM_LEG.ARR_AIRPORT IS ‘到达机场‘
;
COMMENT ON COLUMN CSTL_ASM_LEG.LEG_SEQ IS ‘航节在航程中的次序‘
;
COMMENT ON COLUMN CSTL_ASM_LEG.STATUS IS ‘航段状态‘
;
COMMENT ON COLUMN CSTL_ASM_LEG.CONTEXT IS ‘换飞机上下文状态,AEC,REA,SEA,PO分别对应四个bit‘
;
COMMENT ON COLUMN CSTL_ASM_LEG.DEP_TIME IS ‘航段实际起飞时间‘
;
COMMENT ON COLUMN CSTL_ASM_LEG.DEP_TIME IS ‘航段计划起飞时间‘
;
CREATE TABLE CSTL_ASM_SEAT
(
SEAT_ID NUMBER(18) NOT NULL, -- 座位ID号,主键
LEG_ID NUMBER(18) NOT NULL, -- 航节表ID
SHOW CHAR(1) NOT NULL, -- 矩阵格式显示时的内容
SERVICE_ROW NUMBER(2), -- 真实行号
SERVICE_COL CHAR(1), -- 列号
LOGIC_ROW NUMBER(3), -- 逻辑行号
LOGIC_COL NUMBER(2), -- 逻辑列号
X NUMBER(3) NOT NULL, -- 以矩阵图左上角为原点,向右为正方向的X坐标
Y NUMBER(3) NOT NULL, -- 以矩阵图左上角为原点,向下为正方向的Y坐标
ATTR_1 NUMBER(10), -- 整型记录座位属性1-32bit,从左到右排列。
ATTR_2 NUMBER(10), -- 整型记录座位属性33-64bit,从左到右排列。
ATTR_3 NUMBER(10), -- 整型记录座位属性65-96bit,从左到右排列。
ATTR_4 NUMBER(10), -- 整型记录座位属性97-128bit,从左到右排列。
SEG_RESERVE_RANGE NUMBER(2), -- 保留航段座位长度,用于A属性
ROW_ATTR NUMBER(10), -- 行属性
SECTION_ID NUMBER(2), -- 座位段ID,机舱中以过道分隔,从左到右,从1依次递增。
SECTION_ATTR NUMBER(10), -- 座位段属性
DECK VARCHAR2(1) NOT NULL, -- 甲板代码,U/M/L,默认为L
CLASS VARCHAR2(1) NOT NULL, -- 舱位代码
SUB_CLASS VARCHAR2(1), -- 所属的子舱代码
PRICE_LEVEL VARCHAR2(1), -- 运价等级
SEAT_LEVEL VARCHAR2(5) -- 座位等级
)
TABLESPACE SEAT_CSTL_DAT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 10M
next 1M
minextents 1
maxextents unlimited
)
;
COMMENT ON TABLE CSTL_ASM_SEAT IS ‘航班座位图座位信息表‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.SEAT_ID IS ‘座位ID号,主键‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.LEG_ID IS ‘航节表ID‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.SHOW IS ‘矩阵格式显示时的内容‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.SERVICE_ROW IS ‘真实行号‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.SERVICE_COL IS ‘列号‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.LOGIC_ROW IS ‘逻辑行号‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.LOGIC_COL IS ‘逻辑列号‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.X IS ‘以矩阵图左上角为原点,向右为正方向的X坐标‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.Y IS ‘以矩阵图左上角为原点,向下为正方向的Y坐标‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.ATTR_1 IS ‘整型记录座位属性1-32bit,从左到右排列。‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.ATTR_2 IS ‘整型记录座位属性33-64bit,从左到右排列。‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.ATTR_3 IS ‘整型记录座位属性65-96bit,从左到右排列。‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.ATTR_4 IS ‘整型记录座位属性97-128bit,从左到右排列。‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.SEG_RESERVE_RANGE IS ‘保留航段座位长度,用于A属性‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.ROW_ATTR IS ‘行属性‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.SECTION_ID IS ‘座位段ID,机舱中以过道分隔,从左到右,从1依次递增。‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.SECTION_ATTR IS ‘座位段属性‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.DECK IS ‘甲板代码,U/M/L,默认为L‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.CLASS IS ‘舱位代码‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.SUB_CLASS IS ‘所属的子舱代码‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.PRICE_LEVEL IS ‘运价等级‘
;
COMMENT ON COLUMN CSTL_ASM_SEAT.SEAT_LEVEL IS ‘座位等级‘
;
CREATE TABLE CSTL_ASM_SHARE
(
MC_AIRLINE VARCHAR2(2) NOT NULL, -- 市场方航空公司
MC_NUMBER VARCHAR2(5) NOT NULL, -- 市场方航班号
FLIGHT_DATE DATE NOT NULL, -- 航班天,精确到日
OC_AIRLINE VARCHAR2(2) NOT NULL, -- 承运方航空公司
OC_NUMBER VARCHAR2(5) NOT NULL, -- 承运方航班号
DEP_AIRPORT VARCHAR2(3) NOT NULL, -- 航段的起飞机场
ARR_AIRPORT VARCHAR2(3) NOT NULL, -- 航段的到达机场
OC_FLT_ID NUMBER(9) NOT NULL -- 该共享信息对应的承运方航班ID
)
TABLESPACE SEAT_CSTL_DAT
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 10M
next 1M
minextents 1
maxextents unlimited
)
;
COMMENT ON TABLE CSTL_ASM_SHARE IS ‘记录代码共享关系‘
;
COMMENT ON COLUMN CSTL_ASM_SHARE.MC_AIRLINE IS ‘市场方航空公司‘
;
COMMENT ON COLUMN CSTL_ASM_SHARE.MC_NUMBER IS ‘市场方航班号‘
;
COMMENT ON COLUMN CSTL_ASM_SHARE.FLIGHT_DATE IS ‘航班天,精确到日‘
;
COMMENT ON COLUMN CSTL_ASM_SHARE.OC_AIRLINE IS ‘承运方航空公司‘
;
COMMENT ON COLUMN CSTL_ASM_SHARE.OC_NUMBER IS ‘承运方航班号‘
;
COMMENT ON COLUMN CSTL_ASM_SHARE.DEP_AIRPORT IS ‘航段的起飞机场‘
;
COMMENT ON COLUMN CSTL_ASM_SHARE.ARR_AIRPORT IS ‘航段的到达机场‘
;
COMMENT ON COLUMN CSTL_ASM_SHARE.OC_FLT_ID IS ‘该共享信息对应的承运方航班ID‘
;
-- Create Primary Key Constraints
ALTER TABLE CSTL_ASM_CLASS ADD CONSTRAINT PK_CSTL_ASM_CLASS
PRIMARY KEY (CLS_ID)
USING INDEX TABLESPACE SEAT_CSTL_IDX
;
ALTER TABLE CSTL_ASM_DOLLAR_LEG ADD CONSTRAINT PK_CSTL_DOLLAR_LEG
PRIMARY KEY (LEG_ID)
USING INDEX TABLESPACE SEAT_CSTL_IDX
;
ALTER TABLE CSTL_ASM_FLIGHT ADD CONSTRAINT PK_CSTL_ASM_FLIGHT
PRIMARY KEY (FLT_ID)
USING INDEX TABLESPACE SEAT_CSTL_IDX
;
ALTER TABLE CSTL_ASM_LEG ADD CONSTRAINT PK_CSTL_ASM_LEG
PRIMARY KEY (LEG_ID)
USING INDEX TABLESPACE SEAT_CSTL_IDX
;
ALTER TABLE CSTL_ASM_SEAT ADD CONSTRAINT PK_CSTL_ASM_SEAT
PRIMARY KEY (SEAT_ID)
USING INDEX TABLESPACE SEAT_CSTL_IDX
;
--创建普通索引
CREATE INDEX INDEX_SEAT_LEG_ID ON CSTL_ASM_SEAT(LEG_ID)
TABLESPACE SEAT_CSTL_IDX
;
CREATE INDEX INDEX_CLASS_LEGID ON CSTL_ASM_CLASS(LEG_ID)
TABLESPACE SEAT_CSTL_IDX
;
CREATE INDEX INDEX_FLIGHT_NUMBER ON CSTL_ASM_FLIGHT(AIRLINE,FLIGHT_NUMBER)
TABLESPACE SEAT_CSTL_IDX
;
CREATE INDEX INDEX_LEG_FLTID ON CSTL_ASM_LEG(FLT_ID)
TABLESPACE SEAT_CSTL_IDX
;
CREATE INDEX INDEX_STATUS_DETIME ON CSTL_ASM_DOLLAR_LEG(CHECK_STATUS,DE_TIME)
TABLESPACE SEAT_CSTL_IDX
;
CREATE INDEX SHARE_OC_FLT_ID ON CSTL_ASM_SHARE(OC_FLT_ID)
TABLESPACE SEAT_CSTL_IDX
;
CREATE INDEX SHARE_MC_FLIGHT_NUMBER ON CSTL_ASM_SHARE(MC_AIRLINE, MC_NUMBER, FLIGHT_DATE)
TABLESPACE SEAT_CSTL_IDX
;
------------------
-- 创建自增序列 --
------------------
-- 舱位信息表
create sequence CSTL_ASM_CLASS_SEQ
minvalue 1
maxvalue 9999999999999999
start with 1
increment by 1
cache 3
cycle;
-- 航班信息表,总父表
create sequence CSTL_ASM_FLIGHT_SEQ
minvalue 1
maxvalue 999999999999
start with 1
increment by 1
cycle;
-- 航节信息表
create sequence CSTL_ASM_LEG_SEQ
minvalue 1
maxvalue 99999999999999
start with 1
increment by 1
cycle;
-- 座位信息表
create sequence CSTL_ASM_SEAT_SEQ
minvalue 1
maxvalue 9999999999999999
start with 1
increment by 1
cache 10
cycle;