Security and Integrity

Slides:



Advertisements
Similar presentations
Views-basics 1. 2 Introduction a view is a perspective of the database different users may need to see the database differently; this is achieved through.
Advertisements

1 Term 2, 2004, Lecture 6, Views and SecurityMarian Ursu, Department of Computing, Goldsmiths College Views and Security 3.
Dr. Alexandra I. Cristea CS 252: Fundamentals of Relational Databases: SQL5.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
13 Copyright © Oracle Corporation, All rights reserved. Controlling User Access.
Chapter 23 Database Security and Authorization Copyright © 2004 Pearson Education, Inc.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Database Management System
Cs3431 Constraints Sections 6.1 – 6.5. cs3431 Example CREATE TABLE Student ( sNum int, sName varchar (20), prof int, CONSTRAINT pk PRIMARY KEY (snum),
A Guide to SQL, Seventh Edition. Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT.
System Administration Accounts privileges, users and roles
Database Systems More SQL Database Design -- More SQL1.
A Guide to MySQL 7. 2 Objectives Understand, define, and drop views Recognize the benefits of using views Use a view to update data Grant and revoke users’
Database Systems Lecture 5 Natasha Alechina
The Relational Model. Review Why use a DBMS? OS provides RAM and disk.
By Lecturer / Aisha Dawood 1.  Administering Users  Create and manage database user accounts.  Create and manage roles.  Grant and revoke privileges.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Copyright س Oracle Corporation, All rights reserved. 14 Controlling User Access.
University of Sunderland COM 220Lecture Two Slide 1 Database Theory.
Computer Security: Principles and Practice
Ad Hoc Constraints Objectives of the Lecture : To consider Ad Hoc Constraints in principle; To consider Ad Hoc Constraints in SQL; To consider other aspects.
First Edition by William Stallings and Lawrie Brown Lecture slides by Lawrie Brown Chapter 5 – Database Security.
Controlling User Access. Objectives After completing this lesson, you should be able to do the following: Create users Create roles to ease setup and.
1 Database Administration. 2 Objectives  Understand, create, and drop views  Grant and revoke users’ privileges  Understand and obtain information.
Chapter 6 Database Administration
Copyright © 2013 Curt Hill Database Security An Overview with some SQL.
Metadata, Security, and the DBA Chapter 8.1 V3.0 Napier University Dr Gordon Russell.
Database Management COP4540, SCS, FIU Constraints and security in SQL (Ch. 8.6, Ch22.2)
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1.1 CAS CS 460/660 Relational Model. 1.2 Review E/R Model: Entities, relationships, attributes Cardinalities: 1:1, 1:n, m:1, m:n Keys: superkeys, candidate.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Outline Introduction Basic SQL Setting Up and Using PostgreSQL
1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 6 Data Integrity and Security.
IS 230Lecture 6Slide 1 Lecture 7 Advanced SQL Introduction to Database Systems IS 230 This is the instructor’s notes and student has to read the textbook.
Advanced SQL: Triggers & Assertions
Controlling User Access Fresher Learning Program January, 2012.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
Copyright © 2004, Oracle. All rights reserved. CONTROLLING USER ACCESS Oracle Lecture 8.
Academic Year 2014 Spring Academic Year 2014 Spring.
CSC271 Database Systems Lecture # 17. Summary: Previous Lecture  View updatability  Advantages and disadvantages of views  View materialization.
DATA AND SCHEMA MODIFICATIONS CHAPTERS 4,5 (6/E) CHAPTER 8 (5/E) 1.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Oracle 11g: SQL Chapter 7 User Creation and Management.
13 Copyright © Oracle Corporation, All rights reserved. Controlling User Access.
1 Copyright © 2006, Oracle. All rights reserved. Controlling User Access ( 사용자 접근 제어 )
1 Copyright © 2009, Oracle. All rights reserved. Controlling User Access.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 4: Intermediate.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1 Constraints and Triggers in SQL. 2 Constraints are conditions that must hold on all valid relation instances SQL2 provides a variety of techniques for.
Copyright  Oracle Corporation, All rights reserved. 14 Controlling User Access.
Controlling User Access
Controlling User Access
Security Unit 5.2b Dr Gordon Russell, Napier University
Objectives User access Create users Create roles
TABLES AND INDEXES Ashima Wadhwa.
Managing Privileges.
Database Security and Authorization
ITEC 313 Database Programming
Session #, Speaker Name Database Privileges 11/29/2018.
Advanced SQL: Views & Triggers
Chapter 2 Views.
אבטחת נתונים בסביבת SQL Data Security
Chapter 2 Views.
Presentation transcript:

Security and Integrity Database Systems Lecture 17 Natasha Alechina

Security and Integrity In This Lecture Database Security Aspects of security Access to databases Privileges and views Database Integrity View updating, Integrity constraints For more information Connolly and Begg chapters 6 and 19 Security and Integrity

Security and Integrity Database Security Database security is about controlling access to information Some information should be available freely Other information should only be available to certain people or groups Many aspects to consider for security Legal issues Physical security OS/Network security Security policies and protocols Encryption and passwords DBMS security Security and Integrity

Security and Integrity DBMS Security Support DBMS can provide some security Each user has an account, username and password These are used to identify a user and control their access to information DBMS verifies password and checks a user’s permissions when they try to Retrieve data Modify data Modify the database structure Security and Integrity

Permissions and Privilege SQL uses 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 these to others The owner (creator) of an object has all privileges on that object and can pass them on to others Security and Integrity

Security and Integrity Privileges in SQL GRANT <privileges> ON <object> TO <users> [WITH GRANT OPTION] <privileges> is a list of SELECT <columns>, INSERT <columns>, DELETE, and UPDATE <columns>, or simply ALL <users> is a list of user names or PUBLIC <object> is the name of a table or view (later) WITH GRANT OPTION means that the users can pass their privileges on to others Security and Integrity

Security and Integrity Privileges Examples GRANT ALL 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 Salary values, but cannot change other values or pass on their privilege Security and Integrity

Security and Integrity Removing Privileges If you want to remove a privilege you have granted you use REVOKE <privileges> ON <object> FROM <users> If a user has the same privilege from other users then they keep it All privileges dependent on the revoked one are also revoked Security and Integrity

Security and Integrity Removing Privileges Example ‘Admin’ grants ALL privileges to ‘Manager’, and SELECT to ‘Finance’ with grant option ‘Manager’ grants ALL to Personnel ‘Finance’ grants SELECT to Personnel Admin SELECT ALL Finance Manager SELECT ALL Personnel Security and Integrity

Security and Integrity Removing Privileges Manager’ revokes ALL from ‘Personnel’ ‘Personnel’ still has SELECT privileges from ‘Finance’ ‘Admin’ revokes SELECT from ‘Finance’ Personnel loses SELECT also Admin SELECT ALL Finance Manager ALL SELECT Personnel Security and Integrity

Security and Integrity Views Privileges work at the level of tables You can restrict access by column You cannot restrict access by row Views, along with privileges, allow for customised access Views provide ‘derived’ tables A view is the result of a SELECT statement which is treated like a table You can SELECT from (and sometimes UPDATE etc) views just like tables Security and Integrity

Security and Integrity Creating Views CREATE VIEW <name> AS <select stmt> <name> is the name of the new view <select stmt> is a query that returns the rows and columns of the view Example We want each user to be able to view the names and phone numbers (only) of those employees in their own department Security and Integrity

Security and Integrity View Example Example We want each user to be able to view the names and phone numbers (only) of those employees in their own department In Oracle, you can refer to the current user as USER Employee ID Name Phone Department Salary E158 Mark x6387 Accounts £15,000 E159 Mary x6387 Marketing £15,000 E160 Jane x6387 Marketing £15,000 Security and Integrity

Security and Integrity View Example CREATE VIEW OwnDept AS SELECT Name, Phone FROM Employee WHERE Department = (SELECT Department FROM Employee WHERE name = USER) GRANT SELECT ON OwnDept TO PUBLIC Security and Integrity

Using Views and Privileges Views and privileges are used together to control access A view is made which contains the information needed Privileges are granted to that view, rather than the underlying tables User 1 User 2 User 3 External View 1 External View 2 Conceptual View DBA Security and Integrity

Security and Integrity View Updating Views are like virtual tables Their value depends on the ‘base’ tables that they are defined from You can select from views just like a table What about update, insert, and delete? Updating views Updates to the base tables change the views and vice-versa It is often not clear how to change the base tables to make the desired change to the view Security and Integrity

Security and Integrity View Updating For a view to be updatable, the defining query of the view should satisfy certain 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. used in FROM) WHERE should not have nested SELECTs Should not use GROUP BY or HAVING Security and Integrity

Using Views and Privileges To restrict someone's access to a table Create a view of that table that shows only the information they need to see Grant them privileges on the view Revoke any privileges they have on the original table We want to let the user 'John' read the department and name, and be able to update the department (only) Employee ID Name Salary Department Security and Integrity

Using Views and Privileges Create a view CREATE VIEW forJohn AS SELECT Name, Department FROM Employee Set the privileges GRANT SELECT, UPDATE (Department) ON forJohn TO John REVOKE ALL ON forJohn FROM John Security and Integrity

Security and Integrity 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 Security and Integrity

Domains and Attributes Domains constraints are data types SQL: CREATE DOMAIN (not in Oracle) CREATE DOMAIN Colour CHAR(15) CONSTRAINT checkCol CHECK (VALUE IN (‘RED’,‘Blue’…)) Attributes are constrained by their domains CREATE TABLE Rainbow ( Rorder Int, Rcolour Colour) Security and Integrity

Security and Integrity Assertions Provide a way to give relation and database constraints Give a boolean condition that must always be true No action is permitted that would make the condition false Again, not supported in Oracle CREATE ASSERTION <name> CHECK ( <condition> ) The condition can refer to one or several tables Often use EXISTS or NOT EXISTS Security and Integrity

Security and Integrity Relation Constraints To create a relation constraint We simply make an assertion that checks the constraint Example: in an Employee table, no employee’s bonus should be more than 15% of their salary CREATE ASSERTION checkSalaryBonus CHECK ( NOT EXISTS ( SELECT * FROM EMPLOYEE WHERE (Bonus > 0.15*Salary) ) Security and Integrity

Security and Integrity Database Constraints Database constraints are similar but refer to several tables Example: Given tables student and enrolment, make sure no CS student takes more than 12 modules ID Name Department Student ID Code Enrolment Security and Integrity

Security and Integrity Database Constraints CREATE ASSERTION CSEnrolment CHECK (NOT EXISTS ( SELECT * FROM Student AS S WHERE S.Department = ‘CS’ AND ((SELECT COUNT(*) FROM Enrolment AS E WHERE S.ID = E.ID) > 12))) Security and Integrity

Security and Integrity Constraints in Oracle Oracle does not support domains or assertions It does, however, support row-level constraints using CHECK constraints These are declared like other constraints CONSTRAINT <name> CHECK (<condition>) This is less general than an assertion since the condition refers to a single row of a single table Security and Integrity

Security and Integrity CHECK Example To 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) Security and Integrity

Security and Integrity Next Lecture 'Modern' Databases Distributed DBs Web-based DBs XML and DBs Object Oriented DBs Multimedia DBs For more information Connolly and Begg chapters 22-28 Security and Integrity