数据库完整性与安全性实验 下载本文

(1) 以DBA身份(可以是SQL Server上的sa或者windows上的系统管理组的某个成员)

登陆系统,在图形界面下创建新登录,新建登录用户可以使用Windows认证模式和SQL Server认证模式。

(2) 使用T-SQL命令create login login-name …和create login login-name from windows重复

第1步的内容。

(3) 在服务器角色选项卡中赋予新建用户角色。完成后查找T-SQL中对应命令,在图形界

面上撤消该权限后使用命令完成授予权限和收回权限的任务。

(4) 将新建用户映射到移动通信数据库某用户。执行相关SQL操作,检查该用户的权限。

用户在权限范围内、超出权限范围访问相应数据对象,查看访问结果和DBMS的反映。

(5) 对特定服务器对象设置权限,双击登录名以后选择安全对象,赋予该登录名对服务器

内的某个对象的权限。执行相关SQL操作,检查该用户的权限。用户在权限范围内、超出权限范围访问相应数据对象,查看访问结果和DBMS的反映。 (6) 分别在图形化界面、命令行中,撤销用户权限。 (7) 分别在图形化界面、命令行中,删除数据库用户。

(8) 根据实际操作,指出服务器角色和数据库角色有多少种,分别有什么权限?

(9) 创建数据库时,还会自动创建 SYS、GUEST 和 dbo 组。通过帮助文档,了解这些组在

数据库中起到的作用。 (10)

以DBA身份登陆系统,创建用户组,为用户组授予(grant)或撤销(revoke)针

对数据库中表、视图等不同数据对象的不同访问权限。 (11)

将组成员资格授予现有用户或组,现有用户或组访问数据库对象,查看访问结

果。撤销现有用户或组的组成员资格,查看访问结果。 (12) (13) (14)

分别在图形化界面、命令行中,从数据库删除组。

分别采用Windows认证方式和SQL Server认证方式用不同的用户进行登录连接。 创建数据库角色,并授予访问通信数据库的读、写权限,并对其中的Cell表数据

进行修改。 (15)

将角色赋予(1)中定义的用户,建立用户和角色联系。

a. 再次用此用户访问通信数据库,并对其中的Cell表数据进行修改。

实验环境:

采用SQL Server数据库管理系统作为实验平台。SQL Server要求选用要求使用2005、2008或者2012版本,可以采用SQL Server Express、SQL Server Develop或SQL Server Enterprise等版本。

实验要求:

本实验内容比较繁多,要求同学一定要进行完全的实验,并做出详尽的记录。

实验步骤及结果分析:

一. 建表阶段

1利用SQL语句,分别定义数据库中各基本表的主键、候选键、外键,实现实体完整性约束和参照完整性约束。

2在数据库中选取两张或三张具有外键关联的表,利用语句foreign key-references创建外键,实现参照完整性约束。

3根据实际背景,对某些表中的某些特定属性,定义空值、非空约束。

create table Msc (

MscID char(256) not null, Mscname char(256) null, Msccompany char(256) null, Msclongitude float null, Msclatitude float null, Mscaltitude float null, primary key (MscID) )

create table Bsc (

BscID char(256) not null, Bscname char(256) null, Bscaltitude float null, Bsclatitude float null, Bsclongitude float null, Bsccompany char(256) null, MscID char(256) null, primary key (BscID),

foreign key (MscID) references Msc )

create table Bts (

BscID char(256) null, Btslatitude float null, Btsaltitude float null, Btslongitude float null, Btsname char(256) not null, Btscompany char(256) null, BtsPower int null, primary key (Btsname),

foreign key (BscID) references Bsc )

create table MS (

IMEI char(256) not null, MSISDN char(256) null, gsmMspHeight float null, gsmMspFout float null, gsmMspSense int null, username char(256) null, MScompany char(256) null, Mzone char(10) null, primary key (IMEI) )

create table Cell (

CellID char(256) not null, Btsname char(256) null, Areaname char(256) null, Raidious int null,

Direction int null, BCCH int null, LAC char(256) null, Celllongitude float null, Celllatitude float null, primary key (CellID),

foreign key (Btsname) references Bts )

create table Antenna (

CellID char(256) not null, AntennaHeight float null, HalfPAngle float null, MaxAttenuation float null, Gain float null, AntTilt float null, Pt float null, MsPwr float null, foreign key (CellID) references Cell )

create table Pingdian (

CellID char(256) not null, Freq int not null, primary key (CellID,Freq), check(Freq>=1 and Freq<=124) )

create table neighbourhood (

CellID char(256) not null, AdjectID char(256) not null, CellLac char(256) null, AdjectLac char(256) null, primary key (CellID,AdjectID) )

create table roaddata (

keyNum char(256) not null,

cellID char(256) null, roadlatitude float null, roadlongitude float null, RxLev float null, primary key (keyNum) )

create table tonghuadata (

CellID char(256) not null, traff float null, thtraff float null, rate float null, congsnum float null, callnum int null, callcongs float null, nTCH int null,

Datee datetime not null, Timee datetime not null, primary key (CellID, Datee,Timee) )

create table serverr( IMEI char(256) not null, Btsname char(256) not null, foreign key (IMEI) references MS, foreign key (Btsname) references Bts )

create table fugai( IMEI char(256) not null, CellID char(256) not null, foreign key (IMEI) references MS, foreign key (CellID) references Cell )

create table fuwu( IMEI char(256) not null, CellID char(256) not null, foreign key (IMEI) references MS, foreign key (CellID) references Cell )

create table lucecontrol( keyNum char(256) not null, CellID char(256) not null, foreign key (keyNum) references roaddata, foreign key (CellID) references Cell )

create table huawucontrol( CellID char(256) not null, Datee datetime not null, Timee datetime not null, foreign key (CellID) references Cell, foreign key (CellID,Datee,Timee) references tonghuadata