+ All Categories
Home > Documents > © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410 Authorization ID = user name ...

© D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410 Authorization ID = user name ...

Date post: 18-Jan-2016
Category:
Upload: felix-taylor
View: 223 times
Download: 6 times
Share this document with a friend
23
1 1 © D. Wong 2003 © D. Wong 2003 Security and User Authorization in Security and User Authorization in SQL SQL 8.7 pp. 410 8.7 pp. 410 Authorization ID = user name Authorization ID = user name Special authorization ID: PUBLIC Special authorization ID: PUBLIC Privileges for: Privileges for: SELECT, INSERT, UPDATE, DELETE, SELECT, INSERT, UPDATE, DELETE, REFERENCE, USAGE, TRIGGER, EXECUTE, REFERENCE, USAGE, TRIGGER, EXECUTE, UNDER UNDER For SELECT, INSERT, UPDATE, may also For SELECT, INSERT, UPDATE, may also specify on attribute level specify on attribute level Privileges are needed for relations in Privileges are needed for relations in the subqueries also. e.g. Fig. 8.25 pp the subqueries also. e.g. Fig. 8.25 pp 411 411
Transcript
Page 1: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

11 © D. Wong 2003© D. Wong 2003

Security and User Authorization in SQL Security and User Authorization in SQL 8.7 pp. 410 8.7 pp. 410

Authorization ID = user nameAuthorization ID = user name

Special authorization ID: PUBLICSpecial authorization ID: PUBLIC

Privileges for:Privileges for:

SELECT, INSERT, UPDATE, DELETE, SELECT, INSERT, UPDATE, DELETE, REFERENCE, USAGE, TRIGGER, REFERENCE, USAGE, TRIGGER, EXECUTE, UNDEREXECUTE, UNDER

For SELECT, INSERT, UPDATE, may also For SELECT, INSERT, UPDATE, may also specify on attribute levelspecify on attribute level

Privileges are needed for relations in the Privileges are needed for relations in the subqueries also. e.g. Fig. 8.25 pp 411subqueries also. e.g. Fig. 8.25 pp 411

Page 2: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

22 © D. Wong 2003© D. Wong 2003

Creating privilegesCreating privileges

Owner of schema or modules has all privilegesOwner of schema or modules has all privileges

Establish ownership at:Establish ownership at:

1.1. When a schema is created.When a schema is created.

2.2. When a session is initiated by a CONNECT When a session is initiated by a CONNECT statement.statement.

e.g. e.g. CONNECT TOCONNECT TO ABC_server ABC_server ASAS conn1 conn1 AUTHORIZATIONAUTHORIZATION smith; smith;

3.3. When a module is created, use an optional When a module is created, use an optional AUTHORIZATION clauseAUTHORIZATION clause

Page 3: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

33 © D. Wong 2003© D. Wong 2003

Granting privilegesGranting privileges

Owner of a relation has GRANT privilege.Owner of a relation has GRANT privilege.

If you have the "GRANT" privilege to a set of privileges, you If you have the "GRANT" privilege to a set of privileges, you may grant them to any user. may grant them to any user.

GRANT <privilege list> ON <database element> GRANT <privilege list> ON <database element>

TO <user list> [WITH GRANT OPTION]TO <user list> [WITH GRANT OPTION]

e.g. e.g.

GRANT SELECT, INSERT ON Studio TO kirk, picard GRANT SELECT, INSERT ON Studio TO kirk, picard

WITH GRANT OPTION;WITH GRANT OPTION; -- by Janeway-- by Janeway

GRANT SELECT, INSERT ON Studio TO sisko; -- by picardGRANT SELECT, INSERT ON Studio TO sisko; -- by picard

GRANT SELECT, INSERT(name) ON Studio TO sisko; -- by kirkGRANT SELECT, INSERT(name) ON Studio TO sisko; -- by kirk

Grant diagram e.g. Fig. 8.26 pp. 417 Grant diagram e.g. Fig. 8.26 pp. 417

Page 4: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

44 © D. Wong 2003© D. Wong 2003

Revoking PrivilegesRevoking Privileges

Privileges can be revoked:Privileges can be revoked:

REVOKE [GRANT OPTION FOR] <privilege list> ON <database REVOKE [GRANT OPTION FOR] <privilege list> ON <database element> element> FROM <user list> {CASCADE | RESTRICT}FROM <user list> {CASCADE | RESTRICT}

e.g.e.g.

REVOKE SELECT, INSERT ON Studio FROM picard CASCADE ;REVOKE SELECT, INSERT ON Studio FROM picard CASCADE ;

If A has been given a privilege by several different people If A has been given a privilege by several different people on the same element, then all of them have to revoke in on the same element, then all of them have to revoke in order for A to lose the privilegeorder for A to lose the privilege

If A granted privilege P to B, who granted P to C, then A If A granted privilege P to B, who granted P to C, then A revokes P from B will also revoke P from C. e.g. Fig 8.29 revokes P from B will also revoke P from C. e.g. Fig 8.29 pp 420pp 420

Page 5: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

55 © D. Wong 2003© D. Wong 2003

Object-Oriented Data ModelObject-Oriented Data Model

ODMGODMG

– Object Database Management GroupObject Database Management Group

– Deals with OO standard for databaseDeals with OO standard for database

– Also deals with ORDBMS (Object Relational DBMS)Also deals with ORDBMS (Object Relational DBMS) Major parts of ODMG standard:Major parts of ODMG standard:

– ODL: Object Definition Language, how to specify the ODL: Object Definition Language, how to specify the db schemadb schema

– OQL: the SQL-like Object Query Language OQL: the SQL-like Object Query Language

– Host language binding: how to use ODL and OQL from Host language binding: how to use ODL and OQL from within procedural languages. The standard define within procedural languages. The standard define bindings for C++, SmallTalk, and Java. In ODMG, the bindings for C++, SmallTalk, and Java. In ODMG, the host language also serves as the object manipulation host language also serves as the object manipulation language.language.

Page 6: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

66 © D. Wong 2003© D. Wong 2003

ODMG database management systemODMG database management system Application is written in a host language e.g. C++, JavaApplication is written in a host language e.g. C++, Java In order to access the db, the application must be linked with the In order to access the db, the application must be linked with the

ODBMS libraries and with the code that implements its class ODBMS libraries and with the code that implements its class methods.methods.

Much of the code that manipulates objects is part of the database Much of the code that manipulates objects is part of the database itself.itself.

Each class has a set of methods. Method signatures are specified in Each class has a set of methods. Method signatures are specified in the schema using ODL.the schema using ODL.

The code for these methods is stored on the database server.The code for these methods is stored on the database server. ODBMS invokes the appropriate code whenever a method is ODBMS invokes the appropriate code whenever a method is

called.called. OODMG database data is modified directly in the host language OODMG database data is modified directly in the host language

e.g. Stud.Name = "Joe";e.g. Stud.Name = "Joe"; // Stud contains the oid of a // Stud contains the oid of a // persistent Student object// persistent Student object

Page 7: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

77 © D. Wong 2003© D. Wong 2003

Architecture of an ODMG databaseArchitecture of an ODMG databaseSchema Spec. in ODL(Embedded in C++, Java, etc)

Source code for class methods in host language (C++, Java, …)

Host language compiler

Linker

Method Implementation Binaries Stored in DBMS

ODL Preprocessor

Metadata

Object Data

ODBMS Software

ODBMS Libraries

Method Implementation

Obj. code

Information stored at the Server

Data Access

Ref. "Databases and Transaction Processing" – Lewis, Addison Wesley

Page 8: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

88 © D. Wong 2003© D. Wong 2003

Structure of ODMG ApplicationsStructure of ODMG Applications

ODBMS

ODBMS library

Method implementation

binaries stored in DBMS

Application source code in host language

Host language compiler

Application Object code

Linker

Executable code

Ref. "Databases and Transaction Processing" – Lewis, Addison Wesley

Page 9: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

99 © D. Wong 2003© D. Wong 2003

Object Definition Language (ODL)Object Definition Language (ODL)

Conceptual model to describe the attributes, methods, Conceptual model to describe the attributes, methods, and relationships of each object type (class), including it's and relationships of each object type (class), including it's inheritance properties.inheritance properties.

ODL classes describes 3 kinds of elements:ODL classes describes 3 kinds of elements:

1.1. Attributes: values associated with the objectAttributes: values associated with the object

2.2. Relationship: connection between the object itself and Relationship: connection between the object itself and other objectsother objects

3.3. Methods: functions that may be applied to objects of Methods: functions that may be applied to objects of the class.the class.

Methods are specified by it's signature: name, Methods are specified by it's signature: name, arguments (names, order, and type), return value arguments (names, order, and type), return value type, name of any exceptions it can raise.type, name of any exceptions it can raise.

e.g. Fig. 4.2 pp137e.g. Fig. 4.2 pp137

Page 10: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

1010 © D. Wong 2003© D. Wong 2003

Object Definition Language (ODL) (continued)Object Definition Language (ODL) (continued)

Class declaration Class declaration

Class include:Class include:

1.1. Class NameClass Name

2.2. Key declaration(s). Optional.Key declaration(s). Optional.

3.3. Extent Declaration = name for the set of currently Extent Declaration = name for the set of currently existing objects of a class (I.e. relation instance in existing objects of a class (I.e. relation instance in relational model)relational model)

4.4. Element declarations: attributes, relationships, Element declarations: attributes, relationships, methodsmethods

classclass <name> [ <name> [(extent(extent names names))] ]

{{ < list of elements> < list of elements> }}

Page 11: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

1111 © D. Wong 2003© D. Wong 2003

Object Definition Language (ODL) (continued 2)Object Definition Language (ODL) (continued 2)

Attribute declaration (non-objects):Attribute declaration (non-objects):

attributeattribute <type> <name> <type> <name>;;

e.g. 1 attribute string name;e.g. 1 attribute string name;

e.g. 2 attribute Struct Addr{ string street, string city} e.g. 2 attribute Struct Addr{ string street, string city} address;address;

Relationship (and inverse relationship) declaration Relationship (and inverse relationship) declaration (objects):(objects):

relationshiprelationship [rangetype] [rangetype]<<classNameclassName>> <name> <name> inverseinverse className::<relationship name>;className::<relationship name>;

e.g. e.g. relationship Set<relationship Set<StarStar>> starsstars

inverseinverse Star:: Star::starredInstarredIn;;

Page 12: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

1212 © D. Wong 2003© D. Wong 2003

Method declarationMethod declaration

<returnType> <methodName> (arguments) raises <returnType> <methodName> (arguments) raises (<exception>);(<exception>);

e.g. 1: void lengthInhours() raises (noLengthFound);e.g. 1: void lengthInhours() raises (noLengthFound);

e.g. 2: void starName(out Set<String>) ;e.g. 2: void starName(out Set<String>) ;

Arguments:Arguments:

in : read-onlyin : read-only

out: for returning valuesout: for returning values

inout: for bothinout: for both

Page 13: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

1313 © D. Wong 2003© D. Wong 2003

ODL RelationshipsODL Relationships

Only binary relationships supportedOnly binary relationships supported

– Use a connecting class to represent multiway Use a connecting class to represent multiway relationships Fig. 2.9 pp. 34. relationships Fig. 2.9 pp. 34.

Relationships are defined in inverse pairs. Fig. Relationships are defined in inverse pairs. Fig. 4.3 pp 1404.3 pp 140

1.1. Many-many: have a set type of class in each Many-many: have a set type of class in each directiondirection

2.2. Many-one: a set type for the one, and a simple Many-one: a set type for the one, and a simple class name for the manyclass name for the many

3.3. One-one: simple class name in bothOne-one: simple class name in both

Page 14: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

1414 © D. Wong 2003© D. Wong 2003

Subclass (S is a subclass of D)Subclass (S is a subclass of D)

ClassClass C C extendsextends D { class C's declarations } D { class C's declarations }

e.g. e.g. classclass Cartoon Cartoon extendsextends Movie { Movie {

relationship Set<relationship Set<StarStar>> voices; voices;

}}

Multiple inheritance (separate the super classes by : in the Multiple inheritance (separate the super classes by : in the extend declaration)extend declaration)

e.g. e.g. classclass CartoonMurderMystery CartoonMurderMystery

extendsextends MurderMystery MurderMystery : : Cartoon Cartoon

Name conflict resolutions with Multiple inheritance pp. Name conflict resolutions with Multiple inheritance pp. 151151

Page 15: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

1515 © D. Wong 2003© D. Wong 2003

ODL data typesODL data types

Basis:Basis:

1.1. Atomic type: integer, float, characters, string, Atomic type: integer, float, characters, string, boolean, enumboolean, enum

2.2. Class namesClass names Structured types:Structured types:

1.1. Set: Set<T> // finite sets of elements of type TSet: Set<T> // finite sets of elements of type T

2.2. Bag: Bag<T> // finite bags of element type TBag: Bag<T> // finite bags of element type T

3.3. List: List<T> // finite lists of 0 or more elements TList: List<T> // finite lists of 0 or more elements T

4.4. Array: Array <T, i>Array: Array <T, i> // T = type, i = no. of elements // T = type, i = no. of elements

5.5. Dictionary: Dictionary <T, S>, T is key type, S is Dictionary: Dictionary <T, S>, T is key type, S is range type. Each pair has unique key value.range type. Each pair has unique key value.

6.6. Structures : Struct N {<type1> field1, …}Structures : Struct N {<type1> field1, …}

Page 16: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

1616 © D. Wong 2003© D. Wong 2003

Keys declaration in ODLKeys declaration in ODL

Optional because each object is identified by an internal Optional because each object is identified by an internal OIDOID

May declare one or more keys in the extent declarationMay declare one or more keys in the extent declaration

e.g. class Moviee.g. class Movie

(extent Movies key (title, year))(extent Movies key (title, year))

{{

attribute string title;attribute string title;

attribute integer year;attribute integer year;

……

}}

Page 17: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

1717 © D. Wong 2003© D. Wong 2003

ODL to Relational DesignODL to Relational Design

Invent a new attribute to serve as key when there Invent a new attribute to serve as key when there is no key in the ODL designis no key in the ODL design

ODL attributes that are not atomic are converted ODL attributes that are not atomic are converted into relation attributes that usually are redesigned into relation attributes that usually are redesigned with normalizationwith normalization

Methods are not converted to relational design. Methods are not converted to relational design. But can have methods in Object Relational designBut can have methods in Object Relational design

Page 18: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

1818 © D. Wong 2003© D. Wong 2003

Object-Relational DB (ORDB)Object-Relational DB (ORDB)

SQL-99 adopted a limited subset of the object relational SQL-99 adopted a limited subset of the object relational modelmodel

ORDBMS is a conservative extension to the existing ORDBMS is a conservative extension to the existing RDBMS.RDBMS.

In general, ORDB consists of:In general, ORDB consists of:

– A set of relations (which can be viewed as classes)A set of relations (which can be viewed as classes)

– Each relation consists of a set of tuples (which can be Each relation consists of a set of tuples (which can be viewed as instances of the class that represents the viewed as instances of the class that represents the relation)relation)

– Each tuple is of the form (oid, val) where oid is an Each tuple is of the form (oid, val) where oid is an object id and val is a tuple value whose components can object id and val is a tuple value whose components can be arbitrary values (e.g. primitive values, sets of tuples, be arbitrary values (e.g. primitive values, sets of tuples, and references to other objects)and references to other objects)

Page 19: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

1919 © D. Wong 2003© D. Wong 2003

ORDB, ODB, RDBORDB, ODB, RDB

Difference between ORDB and ODBDifference between ORDB and ODB

– In ORDB, the top-level structure of each object In ORDB, the top-level structure of each object instance is always a tuple. In ODB, top-level instance is always a tuple. In ODB, top-level structure can be an arbitrary value.structure can be an arbitrary value.

Difference between ORDB and RDB:Difference between ORDB and RDB:

– RDB tuple components must be primitive RDB tuple components must be primitive valuesvalues

– ORDB tuple components can be arbitrary ORDB tuple components can be arbitrary valuesvalues

Page 20: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

2020 © D. Wong 2003© D. Wong 2003

Oracle Object exampleOracle Object example

create type create type ADDRESS_TYADDRESS_TY as object as object(Street (Street VARCHAR2(50),VARCHAR2(50), CityCity VARCHAR2(25),VARCHAR2(25), StateState CHAR(2),CHAR(2), ZipZip NUMBER);NUMBER);

create type create type PERSON_TYPERSON_TY as object as object(Name(Name VARCHAR2(25),VARCHAR2(25), BirthDate DATE;BirthDate DATE; AddressAddress ADDRESS_TYADDRESS_TY member function member function AGE_DAYSAGE_DAYS (BirthDate IN DATE) (BirthDate IN DATE) return NUMBERreturn NUMBER););

Page 21: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

2121 © D. Wong 2003© D. Wong 2003

Oracle Object example (continued)Oracle Object example (continued)

Defining methods for user defined types using PL/SQL:Defining methods for user defined types using PL/SQL:

Create type body Create type body PERSON_TYPERSON_TY as as

Member function AGE_DAYS (BirthDate DATE) Member function AGE_DAYS (BirthDate DATE)

return NUMBER isreturn NUMBER is

beginbegin

RETURN ROUND(SysDate – BirthDate);RETURN ROUND(SysDate – BirthDate);

end;end;

-- if there are more methods to the data type, may define here-- if there are more methods to the data type, may define here

end;end;

//

Page 22: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

2222 © D. Wong 2003© D. Wong 2003

Oracle Object example (continued 2)Oracle Object example (continued 2) Create table with user defined abstract data types:Create table with user defined abstract data types:

create table CUSTOMERcreate table CUSTOMER(Customer_ID NUMBER,(Customer_ID NUMBER, PersonPerson PERSON_TYPERSON_TY););

Use constructors for inserting data:Use constructors for inserting data:insert into CUSTOMER values (1, insert into CUSTOMER values (1, PERSON_TY(PERSON_TY('Joe Smith', '01-'Joe Smith', '01-

JAN-90',JAN-90', ADDRESS_TYADDRESS_TY('10 Spring ST', 'BHM', 'AL', 35110('10 Spring ST', 'BHM', 'AL', 35110))))););

Use path names to access the attributes:Use path names to access the attributes:

SELECT Person.Address.StreetSELECT Person.Address.StreetFROM CUSTOMER;FROM CUSTOMER;

SELECT Person.AGE_DAYS(Person.BirthDate)SELECT Person.AGE_DAYS(Person.BirthDate)FROM CUSTOMER;FROM CUSTOMER;

UPDATE CUSTOMERUPDATE CUSTOMERSET Person.Address.City = 'Birmingham'SET Person.Address.City = 'Birmingham'WHERE Person.Address.City = 'BHM';WHERE Person.Address.City = 'BHM';

Page 23: © D. Wong 2003 1 Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:

2323 © D. Wong 2003© D. Wong 2003

Object-Orient Analysis and DesignObject-Orient Analysis and Design

Normalization in relational model relates each attribute to Normalization in relational model relates each attribute to its primary keyits primary key

e.g. The following is in 3NF:e.g. The following is in 3NF:create table CUSTOMERcreate table CUSTOMER

(Customer_ID NUMBER,(Customer_ID NUMBER, Name Name VARCHAR2(25),VARCHAR2(25), BirthDate DATE;BirthDate DATE; Street Street VARCHAR2(50),VARCHAR2(50), CityCity VARCHAR2(25),VARCHAR2(25), StateState CHAR(2),CHAR(2), ZipZip NUMBERNUMBER););

For OO, further group related columns into abstract data For OO, further group related columns into abstract data types (ADT) (e.g. types (ADT) (e.g. ADDRESS_TYADDRESS_TY) for reuse.) for reuse.

Then look for relationships among ADTs to determine if Then look for relationships among ADTs to determine if nesting is appropriate (e.g. nesting is appropriate (e.g. PERSON_TYPERSON_TY););


Recommended