2. 数据库关系图
3. 流程图
开 始 输入用户名和密码 判断用户名和密码是否正确 否 错误提示 是 否 管理员? 是 是 成功登录 界面 客户? 结 束 4.数据库逻辑结构
根据房屋出租管理系统的功能要求,选取SQL Server 2008 作为后台数据库此数据库主要有这几部分:基本表、视图、存储过程、触发器、约束、规则、安全性(新建登录名)。
A. 基本表
基本表系统中有4个表,这四个表分别是:登录表(登录)、出租人信息表(Renter)、房屋信息表(RoomInfo)、承租客户表(Customer)。 1)
登录表(登录)是对管理员名、密码和用户名、密码的保存。 字段名 姓名 密码 权限 2)
出租人信息表(Renter)是对出租人信息的记录。 字段名 RenterID RenterName Contact ContactID RenterRental Remark 3)
房屋信息表(RoomInfo)是对房屋信息的记录 字段名 RoomID RenterID RoomType Location Floor 数据结构 char char char vachar vachar 说明 主键、非空、长度4 非空、长度18 长度20 长度50 长度2 数据类型 Char Varchar Varchar Char Money Varchar 说明 主键、非空、长度18 长度20 长度50 非空、长度8 非空、长度8 长度50 数据结构 Char nvarchar char 说明 非空、长度10 非空、长度50 非空、长度10 RatingNum TrueNum Area Price AirCondition Telephone TV WashRoom Kitchen Internet Remark 4)
字段名 CustomerID CustomerName Sex NativePlace IDCard RoomID InDate RentalDate ContractID CustomerRental Remark smallint smallint smallint Money bit bit bit bit bit bit vachar 长度2 长度2 长度2 非空、长度8 长度1 长度1 长度1 长度1 长度1 长度1 长度50 承载客户表(Customer)是对承载客户信息的记录
数据结构 char vachar char vachar char char datetime datetime char money vachar 说明 主键、非空、长度18 长度20 长度2 长度50 长度18 非空、长度4 非空、长度8 长度8 非空、长度8 非空、长度8 长度50 B. 视图
视图数据库中有两个视图,分别是客户信息视图(View_CustomerInfo)和房屋信息视图(View_RoomInfo)。 1)
客户信息视图(View_CustomerInfo)基于三个表:出租人信息表(Renter)、房屋信息表(RoomInfo)、承租客户表(Customer)。 构建此视图所用的SQL脚本如下:
SELECT TOP (100) PERCENT dbo.Customer.CustomerName,
dbo.RoomInfo.RoomType, dbo.RoomInfo.Price, dbo.Customer.CustomerID, dbo.RoomInfo.RoomID, dbo.Renter.RenterRental, dbo.Customer.InDate,
dbo.Customer.RentalDate, dbo.Customer.CustomerRental,
dbo.Customer.CustomerRental - dbo.Renter.RenterRental
AS TrueProfit
FROM dbo.Customer INNER JOIN
dbo.RoomInfo ON dbo.Customer.RoomID = dbo.RoomInfo.RoomID INNER JOIN
dbo.Renter ON dbo.RoomInfo.RenterID = dbo.Renter.RenterID
ORDER BY dbo.Customer.CustomerID