www.cardiff.ac.uk/medic/irg-clinicalepidemiology
Security and integrity
Copyright By PowCoder代写 加微信 powcoder
Information modelling
& database systems
in this lecture we will consider briefly a range of issues concerning database applications
database security
aspects of security
access to databases
privileges and views
database integrity
view updating
integrity constraints
Database security
database security is about controlling access to information
some information should be available freely
other information should only be available to certain users
many different aspects of security:
legal issues
physical security
OS/network security
security policies and protocols
encryption and passwords
DBMS security
DBMS security support
DBMS can provide some security
each user has an account name and password
these are used to identify a user and control their access to information
DBMS verifies user’s password and checks their permissions whenever they try to
modify data
modify the database structure
Privileges
Privileges
SQL uses different privileges to control access to tables and other database objects
SELECT privilege
INSERT privilege
UPDATE privilege
DELETE privilege
the owner (creator) of a database has all privileges on all objects in the database and can grant privileges to other users
the owner (creator) of an object has all privileges on that object and can pass them on to others
Privileges in SQL
GRANT
ON
TO
[WITH GRANT OPTION]
SELECT
INSERT
UPDATE
table or view
list of users
allows the specified users to pass their privileges to other users
ON Employee
TO Manager
WITH GRANT OPTION
the user Manager can do anything to the Employee table, and can allow other users to do the same (by using GRANT statements)
GRANT SELECT, UPDATE(Salary)
ON Employee
TO Finance
the user Finance can view the entire Employee table, and can change values in its Salary column, but cannot change any other values or pass on their privilege to other users
Removing privileges
a previously granted privilege can be revoked using the following statement:
REVOKE
ON
FROM
if a user was granted the same
privilege from some other user,
then they will still keep it
all other privileges that depend on the revoked one will be revoked automatically
Admin grants ALL to Manager WITH GRANT OPTION
Admin grants SELECT to Finance WITH GRANT OPTION
Manager grants ALL to Personnel
Finance grants SELECT to Personnel
Manager revokes ALL from Personnel
Personnel still has SELECT privilege from Finance
Admin revokes SELECT from Finance
Personnel loses SELECT privilege
privileges work at the level of tables
access can be restricted by columns
access cannot be restricted by row!
views, together with privileges, allow for customised access control
a view is a table that is derived as the result of a SELECT statement
SELECT statement can then be used with views in the same way tables can
UPDATE statement can sometimes be used with views
Creating views
CREATE VIEW
AS
the name of the newly created view
a query that returns the rows and the columns of the view
we want each user to be able to view the names and phone numbers only of those employees in their own department
note: in Oracle, you can refer to the current user using the keyword USER
CREATE VIEW OwnDept AS
SELECT Name, Phone
FROM Employee
WHERE Department = (SELECT Department
FROM Employee
WHERE name = USER);
GRANT SELECT ON OwnDept TO PUBLIC;
ID Name Phone Department Salary
S123 J Evans x70320 Finance £30000
S234 L Davies x70871 Marketing £35000
S345 R Jenkins x75600 Marketing £35000
… … … … …
Views and privileges
views and privileges are combined to control access
create a view that contains the information needed
grant privileges to that view, rather than the underlying tables
views are virtual tables
their content depends on the underlying tables
we can select from views just like a table
… but what about update, insert, and delete?
Updating views
updates to the underlying tables will change the views
for a view itself to be updatable, the defining query has to satisfy the following conditions:
every element in SELECT is a column name
should not use DISTINCT
view should be defined on a single table (no JOIN, UNION, etc.)
WHERE should not have nested SELECT statements
should not use GROUP BY or HAVING
Access control with views and privileges
to restrict a user’s access to a table …
create a view of that table that shows only the information the user needs to see
grant the user privileges on the view
revoke any privileges the user has on the original table
Employee(ID, Name, Salary, Department)
we want to let the user John see Department and Name, and be able to update Department (only)
creating a view
CREATE VIEW JohnsView
AS SELECT Name, Department FROM Employee;
setting the privileges
GRANT SELECT, UPDATE(Department)
ON JohnsView TO John;
REVOKE ALL ON Employee FROM John;
Database integrity
Security vs. integrity
database security makes sure that the user is authorised to access information
database integrity makes sure that (authorised) users use that information correctly
integrity constraints:
domain constraints apply to data types
attribute constraints apply to columns
relation constraints apply to rows in a single table
database constraints apply between tables
Domains and attributes
domain constraints are data types
SQL statement: CREATE DOMAIN (note: not in Oracle)
CREATE DOMAIN Colour VARCHAR(15)
CONSTRAINT checkCol CHECK (VALUE IN (‘red’,’blue’,…);
attributes are constrained by their domains
CREATE TABLE Dress
col Colour
Assertions
assertions provide a way to specify relation and database constraints
CREATE ASSERTION CHECK ();
assertions state a Boolean condition that must always be true
no action is permitted that would make the condition false
can refer to one or several tables
often use EXISTS or NOT EXISTS
note: not supported in Oracle!
Relation constraints
to create a relation constraint we simply create an assertion that checks the given constraint
e.g. in the Employee table, no Bonus should be more than 15% of the employee’s Salary
CREATE ASSERTION checkSalaryBonus CHECK
NOT EXISTS
FROM Employee
WHERE Bonus > 0.15*Salary
Database constraints
database constraints are similar to relation constraints,
but they refer to multiple tables
e.g. given tables Student(ID, Name, Department) and Enrolment(ID, Module), make sure no computer science student takes more than 12 modules
CREATE ASSERTION CSEnrolment CHECK
NOT EXISTS
FROM Student AS S
WHERE S.Department = ‘computer science’
AND ((SELECT COUNT(*) FROM Enrolment AS E
WHERE S.ID = E.ID) > 12
Constraints in Oracle
Oracle does not support domains or assertions!
… but it does support row–level constraints using
CHECK
row–level constraints are declared like other constraints:
CONSTRAINT CHECK ();
less general than assertions since the condition refers to a single row of a single table
add a check on the Employee table to make sure no employee’s Bonus is more than 15% of their Salary
ALTER TABLE Employee
ADD CONSTRAINT checkSalaryBonus
CHECK (Bonus < 0.15*Salary);
/docProps/thumbnail.jpeg
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com
Post navigation
← Previous PostNext Post →
Related Posts
matlab simulation
程序代写 CS代考 / matlab代写代考, simulation
AB202 Assignment 1: Arkapong
程序代写 CS代考 / c++代做
MSc C++ Programming
程序代写 CS代考 / c++代做
MSc Assessed Prolog Lab Exercise 2
程序代写 CS代考 / Prolog代写代考
Spring Session:2015:Assignment 1
程序代写 CS代考 / c++代做, UML
Assignment 2: "Inception and Elaboration"
程序代写 CS代考 / UML
android app
程序代写 CS代考 / android, Java代写代考
COMP220: Software Development Tools
程序代写 CS代考 / Java代写代考, junit
Contact
QQ: 1823890830
微信号(WeChat): powcoder
Email: powcoder@163.com
请加微信或QQ发要求
Contact me through WeChat
Categories
机器学习代写代考 machine learning
数据库代写代考 DB Database SQL
数据结构算法代写代考 data structure algorithm
人工智能 AI Artificial Intelligence
编译器原理 Compiler
计算机网络 套接字编程 computer network socket programming
大数据 Hadoop Map Reduce Spark HBase
操作系统OS代写代考 (Operating System)
计算机体系结构代写代考 Computer Architecture
计算机图形学 Computer Graphics opengl webgl
自然语言处理 NLP natural language processing
并行计算
计算理论 Theory of Computation
计算机安全密码学computer security cryptography
系统编程 System programming
数值科学计算
计算机视觉代写代考(Compute Vision)
网页应用 Web Application
分布式系统
笔试面试
函数式编程
数据挖掘 Data Mining
离散数学代写代考 (Discrete mathematics)
软件工程
编程语言 Programming Language
统计代写代考
运筹学 Operation Research
TagAlgorithm算法代写代考Java代写代考databasedata structurePython代写代考compilerScheme代写代考C语言代写AI代写c++代写SQL代写代考Haskell代写代考javascriptconcurrencymatlab代写代考financeinterpreterMIPS汇编代写代考data miningdecision treedeep learning深度学习代写代考Prolog代写代考file systemc++代做computer architectureERguiGPUdata sciencex86汇编代写代考case studydistributed systemandroidkernelARM汇编代写代考
程序代写 CS7641 Assignment 4 Markov Decision Processes Fall 2024
CS代写 CS 0447 Computer Organization and Assembly Language Midterm Project – Conne
CS代考 CS 0447 Computer Organization and Assembly Language Midterm Project – Conne
计算机代写 CS7641 Assignment 4 Markov Decision Processes Fall 2024
计算机代写 COMP9313 Project 3
Copyright © 2025 PowCoder代写 | Powered by Astra WordPress Theme