毕业设计(论文)-基于JAVA的邮件收发系统的设计.doc_第1页
毕业设计(论文)-基于JAVA的邮件收发系统的设计.doc_第2页
毕业设计(论文)-基于JAVA的邮件收发系统的设计.doc_第3页
毕业设计(论文)-基于JAVA的邮件收发系统的设计.doc_第4页
毕业设计(论文)-基于JAVA的邮件收发系统的设计.doc_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

基于基于 JAVAJAVA 的邮件收发系统的设计的邮件收发系统的设计 摘摘 要要 WISE 系统 是一个功能强大的数据处理系统 它应用于某公司 此公 司由于行业的关系需要它去处理庞大的数据 这些数据每天都在以上百万条甚 至上亿条的数量在增加 因此它需要处理海量的数据 它的其中一个比较重要 的功能是根据复杂并且灵活的条件筛选出适当的数据返回给客户 本论文主要 讲述了如何针对数据筛选条件比较复杂并且比较灵活这一需求 在做了详尽的 需求分析之后 进行了一系列的设计 包括解决方案的设计 数据建模 PL SQL 程序设计 最终完成整个数据筛选接口的设计 在整个数据筛选接口的 设计中 在传统的关系性数据库的基础上 会尝试着应用一些面向对象的思想 去设计 尤其在数据建模阶段 通过传统的数据模型之间的关系 例如主外键关系 实 现了一些重要的面向对象的思想 关键字关键字 数据筛选 面向对象 数据建模 PL SQL Implement the Object Oriented thinking in the project to data modeling the design about the API to filter data Abstract The WISE system is a powerful system for data processing It is applied in a company which needs to use this system to process huge amount data And these data will be increased by millions or hundreds millions So it needs to process the huge amount data One of its important function is return the right data to client filtered by some complex and flexible conditions The most content of the paper talks about how to finish the total design for the requirement which is the conditions to filter data can be complex and flexible The entire design will include the design of project to solve problem the design about data modeling and the design about PL SQL program Finally the all designs to implement the interface for filtering the data are finished We will try implementing the object oriented thinking to design on the base of the relational database in the process to finish all the design Especially in the process to implement data modeling we will implement some important object oriented thinking by some relations among traditional data models such as PK or FK relationship Key words data filtration object oriented data modeling PL SQL 目目 录录 论文总页数 24 页 1 引 言 1 2 开发概述 1 3 需求分析 1 3 1 需求调研 1 3 2 开发运行环境 3 4 解决方案的设计 3 5 数据建模 8 5 1 数据模型的建立 8 5 2 数据库表结构的设计 9 5 3 数据库基础视图的设计 11 6 PL SQL 程序设计 12 结 论 22 参考文献 22 第 1 页 共 24 页 1 1 引引 言言 当今社会 某些行业的数据量越来越庞大 每天都在以上百万条甚至上亿 条的数量在增加 因此对这些行业的数据处理系统的性能要求也越来越高 这 些要求不但包括处理速度尽可能快 系统可维护性尽可能高等传统需求 而且 增加了对数据的处理尽可能的灵活等一些新的需求 要满足这些新的需求 我 们需要研究这些新需求的特性 挖掘一些解决办法 面向对象的数据建模是我 们研究的一个重要方向 引用言论 Steve Hoberman 所提出的 抽象组件 的概念和面向对象设计 中的 设计模式 非常类似 即数据库专家在多次的数据建模后 将各个项目 中的类似部分抽象化 提取出特定的建模模型片段 以后只需在新的项目中对 这些模型片段细化派生 即可快速构建出适合于该项目的数据库架构 2 2 开发概述开发概述 WISE 系统 是一个功能强大的数据处理系统 由于业务的关系 它需要 处理海量的数据 它的比较重要的一个功能是根据复杂并且灵活的条件筛选出 适当的数据返回给客户 针对这一数据筛选功能 开发的目标是设计一个合理的数据筛选接口 接 口能做到便于动态控制 便于动态修改 以及便于维护 开发的过程包括需求分析 解决方案的设计 数据建模 PL SQL 程序设计 最终完成整个数据筛选接口的设计 3 3 需求分析需求分析 3 3 1 1 需求调研需求调研 WISE 系统是某公司的数据处理系统 它的一个主要功能是每天根据复杂并 且灵活的条件筛选出适当的数据返回给客户 所筛选的数据都来自于一张表 这张表的字段有 260 个 这些字段中有超过 250 个字段需要作为筛选字段 它 们通常互为组合去筛选出客户需要的数据 根据客户的需要它们的组合又是多 变的 这张表的数据量通常在一千万到一亿条记录之间 值得注意的是 筛选 条件需要去匹配的值是具有特定意义的 尽管这些值数目众多 但它们的数量 不是随意增长的 而且这些值是根据客户的需求可以去定制的 第 2 页 共 24 页 表 1 复杂表 Complexity 字段名数据类型说明 C ID 数字主键 C U1 文本 C U2 文本 C U13 文本 C U4 货币 C U5 数字 C U6 货币 C U7 文本 C U8 货币 C U9 文本 C U10 货币 C U11 文本 C U12 文本 C U13 日期 时间 C U14 日期 时间 C U15 数字 C U16 数字 C U17 文本 C U18 文本 C U19 文本 C U20 货币 C U21 数字 C U22 货币 C U23 文本 C U24 货币 C U25 文本 等等一共 260 个字段 第 3 页 共 24 页 因此对数据筛选的需求特点主要有 数据筛选需求特点 数据量庞大 来自于一张表 表的字段较多 大多 数为筛选字段 筛选字段通常组合 组合较为灵活 筛选列去需要去匹配的值 有特定 意义 客户可以定制 图 1 需求特点分析图 数据量庞大在这里不是本次设计的研究重点 后三个特点是本次设计要解 决好的需求 3 3 2 2 开发运行环境开发运行环境 开发所需的基本软 硬件环境为 Windows 2003 或者 Windows XP Oracle 10 g R2 CPU 2 40GHz 1G 以上内存 2G 以上可用硬盘空间 在 Windows 2003 操作系统下 以 Toad for Oracle Xpert v9 0 1 8 为开 发工具 用 Oracle 10 g R2 为后台数据库 4 4 解决方案的设计解决方案的设计 在这里来逐步分析需求应该通过怎样的方式来实现 进行一些解决方案的 设计 方案方案 1 1 直接写过程来实现 根据不同的筛选条件 写不同的过程来实现数据筛选 问题 很显然 这种方案是行不通的 由于筛选字段数量达两百多个 而 第 4 页 共 24 页 且相互之间可以互为组合 所以是不应该写过程来实现的 即便把目前需求要 求的筛选条件通过写过程来实现了 暂不考虑开发人员的头疼 如果需要添加 一些新的筛选 那将是非常麻烦的 再则 如果所写过程中出现一些问题 也 是难以维护的 所以考虑到开发的质量与代码的可维护性 是不可能采用此方案的 方案方案 2 2 结合数据建模与程序设计来实现 由于筛选条件数量众多 但是条件之间的很多部分相互重合 从面向对象 的角度出发 这些条件间存在继承的关系 如果能采用面向对象的方法 或许 能做到重用条件 假设一共有 250 个独立的筛选条件 也即表中的 250 个字段单独作为条件 时的情况 这些条件能相互组合 组合后的条件越发复杂 写程序时如果按照 方案 1 要想做到很好的代码重用是不可能实现的 所以根据方案 1 的失败 要想很好的做到代码重用 就很有必要引入面向 对象的思想 采用继承的方法 做到条件组合 就好像类与类之间的继承 作 为表中列名出现的字段 是不可能相互组合的 但是换个角度 大胆的设想 如果把这些字段不作为列名 能不能做到相互组合呢 如果把这些字段转换成 变量 对变量一一赋值 和作为字段相比并没有做到很大的改善 如果把这些字段转换成表中的记录值呢 试想一下 似乎看到一线光明 因为在 PL SQL 里 可以用到动态 SQL 的方法 这样可以所需要的条件动态的组 合了 但是能不能真正达到便于动态控制 便于动态修改 以及便于维护呢 我 们需要一步一步去研究 以及测试 根据目前得出的结论 我们现在需要一个表 表中的某一列的记录值为 Complexity 表中作为筛选条件的列名 如下表 2 所示 表 2 FIELD 字段名数据类型说明 ID 数字主键 NAME 文本 COLUMN NAME 文本列名 FIELD 表中的 COLUMN NAME 列存放 Complexity 表中作为筛选条件的列名 这样就可以做到把条件一步一步 拼起来 了 接着往下分析 需要选取出可能作为筛选条件的列名 C U1 C U2 C U3 C U4 四个字段 以后的分析将会以它们作为例子 这里把 第 5 页 共 24 页 每个单独的列名作为筛选条件的条件叫做简单条件 而多个简单条件组合而成 的条件叫做复杂条件 值得注意的是 筛选条件中有相当一部分是类似于 C U1 IN A B C D 的 它也是简单条件 但是比较特殊一点 这样的 条件把它叫做简单序列条件 假设现在客户 Ted 需要的数据是以 C U1 A 和 C U2A 和 C U2 A 或者 C U2 B 筛选列和匹配的数值我们都可以 在相关表中取到 而筛选列和匹配的数值之间的关系 例如大于 小于 等于 时间从某时间开始 这些关系是我们在写代码的时候一直在重复的写的 而正 是因为这个原因 代码不能做到代码间的继承和重用 这是一个失败指出 要是通过接口设计能把这些关系像处理筛选列与匹配的数值一样处理 这 个问题也就解决了 能做到么 答案是肯定的 因为这些关系也就只有数种 例如数字间的比较 时间数值之间的比较 诸如此类的关系是可以得到有效控 制的 对于序列条件 只有两种关系 即是否 IN 很显然也可以得到有效的控 制 通过以上的分析 现在只需要再加一个表就可以了 这张表用来存放简单 条件的筛选列与匹配的数值之间的关系种类 而对于序列条件 就不用 在程 序里很容易做到动态处理 为了不占据篇幅 数据筛选接口的完整数据库架构 会在后面的数据建模部分中一并出现 5 5 数据建模数据建模 5 15 1 数据模型的建立数据模型的建立 根据解决方案的设计 画出数据筛选接口的完整数据库架构 如后页图所 示 第 9 页 共 24 页 CONDITION PKID NAME NEGATED CONTAINER ID COMPOUND CONDITION PKID CONJUNCTION ID SIMPLE CONDITION PKID NAME VALUE OPERATOR ID FIELD ID LIST CONDITION PKID FIELD ID CONJUNCTION PKID NAME CODE CONDITION OPERATOR PKID CODE NAME FIELD PKID NAME COLUMN NAME LIST CONDITION MATCH VALUE PKID LIST CONDITION ID MATCH VALUE 图 5 数据库架构图 5 25 2 数据库表结构的设计数据库表结构的设计 5 35 3 数据库基础视图的设计数据库基础视图的设计 通过之前的分析 我发现数据库中的八个表之间关联比较多 应该把通常 发生关联的表封装起来 视图正是实现这个 封装 的最佳选择 需要创建四个视图 分别为简单条件视图 序列条件视图 组合条件视图 以及条件视图 通过这四个视图可以把简单条件 序列条件 以及组合条件和 第 10 页 共 24 页 FIELD 表很好的封装起来 为了避免占据过多篇幅 这里只以序列条件视图和 组合条件视图为例 序列条件视图 CREATE OR REPLACE VIEW V LIST CONDITION FIELD NAME COLUMN NAME FIELD TYPE NAME FIELD TYPE CODE FIELD TABLE TYPE NAME FIELD TABLE TYPE CODE NEGATED ITEM COUNT ID FIELD ID FIELD TYPE ID CONTAINER ID AS select F Name as Field Name F Column Name IC Negated select count from List Cond Match Value LCMV where LCMV List Condition ID LC ID as I Count LC ID F ID as Field ID F Type ID as Field Type ID IC Container ID from List Condition LC left outer join Condition C on C ID LC ID left outer join Field F on F ID LC Field ID 组合条件视图 CREATE OR REPLACE VIEW V COMPOUND CONDITION NEGATED CONJUNCTION NAME CONJUNCTION CODE CONDITION COUNT ID CONTAINER ID CONJUNCTION ID AS select IC Negated C Name as Conjunction Name C Code as Conjunction Code select count from Condition ChildCondition where ChildCondition Container ID CIC ID as Condition Count CC ID IC Container ID CC Conjunction ID from Compound Condition CC left outer join Condition IC 第 11 页 共 24 页 on IC ID CC ID left outer join Conjunction C on C ID CC Conjunction ID 这样就通过创建视图 把简单条件 序列条件 以及组合条件和 FIELD 表 很好的封装起来了 到此 数据建模完成 6 6 PL SQLPL SQL 程序设计程序设计 现在进行本接口设计的 PL SQL 程序设计部分 从客户出发 这里来整理一下思路 当客户提出一系列筛选条件的要求时 开发人员首先需要把这些基本的简单条件和匹配的数值 以及相关的记录值 一一插入相关的表中 开发人员可以用写一系列的过程来实现 通过传入必需 的参数来调用相关的过程 插入一些数值 从下到上 首先要对表直接进行操作 需要一系列最基本的用来实现把数 值插入表的过程 以简单条件为例 procedure Ins Simple Condition p calling user id integer Required p name varchar2 null p negated number 0 Required p container id integer null p field id integer Required p value varchar2 null p enum value id integer null p comparison field id integer null p operator id integer Required p new row id out integer is begin 省略部分代码 Ins Condition p calling user id p name p negated p container id p new row id insert into Simple Condition ID Field ID Value Enum Value ID 第 12 页 共 24 页 Comparison Field ID Operator ID values p new row id p field id p value p enum value id p comparison field id p operator id 省略部分代码 end 然后 需要在这些基础过程之上 写一些调用这些基础过程的过程 也以 简单条件为例 procedure Add Simple Condition p calling user id integer Required p app id integer p table type code varchar2 Required p name varchar2 null p negated number 0 p container id integer null p field name varchar2 Required p value varchar2 null p value date date null p comparison field name varchar2 null p operator code varchar2 Required p new row id out integer is l field id integer l field type code varchar2 100 l comparison field id integer l comparison field type code varchar2 100 l operator code varchar2 100 l operator id integer l value varchar2 1000 begin 省略部分代码 select ID Code into l operator id l operator code from Condition Operator where lower Code lower p operator code 省略部分代码 Ins Simple Condition p calling user id p calling user id 第 13 页 共 24 页 p name p name p negated p negated p container id p container id p field id l field id p value l value p comparison field id l comparison field id p operator id l operator id p new row id p new row id 省略部分代码 end 现在就可以创建一些比较复杂的组合条件了 为了不占据篇幅 这里只以 一个简单的复合条件为例 First compound condition NO NOTICE IN B C D AND MSG DELINQ DAYS 90 AND DO NOT PROCESS 9 AND CLIENT ID 116 declare l calling user id integer l dps appl id integer l count integer l spec id integer l item id integer l simple id integer l inventory item id integer l temp id integer l compound id integer l field id integer l rule id integer l list id integer l state 4 ted1 varchar2 4000 B C D begin 省略部分代码 add condition Add Compound Item condition p name The Fourth compoud condition p negated 0 p conjunction And p container id null p new row id l rule id select id into l field id from field where name NO NOTICE and application id l dps appl id or application id is null 第 14 页 共 24 页 Add List Item condition p name NO NOTICE IN B C D p negated 1 p field id l field id p container id l rule id p new row id l list id for x in with src as select l state 4 ted1 exp from dual num as select rownum I from dual connect by rownum 0 order by r loop Add List Item condition MV p list item condition id l list id p match value x r p new row id l temp id end loop select id into l field id from field where name MSG DELINQ DAYS and application id l dps appl id or application id is null Add Simple Item condition p name null p negated 0 p container id l rule id p field id l field id p value 90 p comparison field name null p operator Greater p new row id l simple id select id into l field id from field where name DO NOT PROCESS and application id l dps appl id or application id is null Add Simple Item condition 第 15 页 共 24 页 p name null p negated 0 p container id l rule id p field id l field id p value 9 p comparison field name null p operator Equals p new row id l simple id select id into l field id from field where name CLIENT ID and application id l dps appl id or application id is null Add Simple Item condition p name null p negated 0 p container id l rule id p field id l field id p value 116 p comparison field name null p operator Equals p new row id l simple id COMMIT end 到此筛选列和需要匹配的数值 就可以得到灵活控制了 还需要对存储在 表CONDITION OPERATOR中的数值 也就是记录筛选列和需要匹配的数值之间的 关系的数值进行处理 以便能动态处理 下面只以需要匹配的数值的数据类型 为日期类型的情况为例 当需要匹配的数值的数据类型为日期类型时 如下 function Comparison Date p row V Simple Condition rowtype p field ref varchar2 p comparison field ref varchar2 return varchar2 is l comparison varchar2 4000 l operator varchar2 2 l value this day date l value this day string varchar2 1000 l value next day date l value next day string varchar2 1000 begin 省略部分代码 if p comparison field ref is not null then 第 16 页 共 24 页 省略部分代码 l value this day string trunc p comparison field ref dd l value next day string trunc p comparison field ref 1 dd else if p row Value is not null then l value this day to date p row Value g date format l value this day string to date p row Value g date format l value next day l value this day 1 l value next day string to date to char l value next day g date format g date format end if end if case p row Operator Code when Equals then if p comparison field ref is not null then if p row Negated 0 then l comparison p field ref is null and p comparison field ref is null or p field ref l value this day string and p field ref l value next day string else l comparison p field ref is null and p comparison field ref is not null or p field ref is not null and p comparison field ref is null or p field ref l value next day string end if else if p row Value is null then if p row Negated 0 then l comparison p field ref is null else l comparison p field ref is not null end if else 第 17 页 共 24 页 if p row Negated 0 then l comparison p field ref l value this day string and p field ref l value next day string else l comparison p field ref is null or p field ref l value next day string end if end if end if when Greater then null if p comparison field ref is not null or p row Value is not null then if p row Negated 0 then l operator else l operator end if l comparison p field ref l operator l value next day string else The value we re checking against is null so we should have no matches l comparison g false condition end if when Less then if p comparison field ref is not null or p row Value is not null then if p row Negated 0 then l operator end if l comparison p field ref l operator l value this day string else The value we re checking against is null so we should have no matches l comparison g false condition end if 第 18 页 共 24 页 else raise application error g error number Unexpected operator p row Operator Code end case 省略部分代码 return l comparison end 总结一下 本接口设计的 PL SQL 程序设计部分是通过如下过程实现了灵活 控制筛选条件 并完成了数据筛选接口的基本部分的 被 调 用 被 调 用 图 6 创造数据筛选条件程序设计图 现在筛选列和需要匹配的数值以及筛选列和需要匹配的数值之间的关系都 可以得到灵活控制了 只需要根据不同的参数调用公共的PL SQL接口 一一 拼装 起来即可 现在还需要通过写过程来实现把这些复杂筛选条件 拼装 起来 最终筛 选出客户需要的数据 这样一个功能 以简单条件为例 function Cond Where Simple 基础操作条件过程1 对数据库的相关条件表进行 操作 包括插入 更新等 基础操作条件过程2 动态处理记录筛选列和需 要匹配的数值之间的关系 的数值 调用基础条件过程 用于创造一些复杂的组 合条件 第 19 页 共 24 页 p item condition id integer p index field prefix varchar2 return varchar2 is Required l where clause varchar2 4000 l row V Simple Item Condition rowtype l effective prefix varchar2 100 l field ref varchar2 1000 l comparison field ref varchar2 1000 null begin 省略部分代码 l effective prefix if p index field prefix is not null then l effective prefix p index field prefix end if l where clause select into l row from V SimpleCondition where ID p item condition id l field ref l effective prefix l row Column Name if l row Comparison Column Name is not null then l comparison field ref l effective prefix l row Comparison Column Name end if case l row Field Type Name when Boolean then l where clause l where clause Comparison Boolean l row l field ref l comparison field ref when Date then l where clause l where clause Comparison Date l row l field ref l comparison field ref when List then l where clause l where clause Comparison String l row l field ref l comparison field ref when Number then l where clause l where clause Comparison Number l row l field ref l comparison field ref when String then l where clause l where clause Comparison String l row l field ref l comparison field ref else 省略部分代码 end case

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论