Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Chapter 2 Database Environment Transparencies © Pearson Education Limited 1995, 2005.

Similar presentations


Presentation on theme: "1 Chapter 2 Database Environment Transparencies © Pearson Education Limited 1995, 2005."— Presentation transcript:

1 1 Chapter 2 Database Environment Transparencies © Pearson Education Limited 1995, 2005

2 2 ANSI-SPARC Three-Level Architecture © Pearson Education Limited 1995, 2005

3 3 ANSI-SPARC Three-Level Architecture u External Level –Users’ view of the database. –Describes that part of database that is relevant to a particular user. u Conceptual Level –Community view of the database. –Describes what data is stored in database and relationships among the data. © Pearson Education Limited 1995, 2005

4 4 ANSI-SPARC Three-Level Architecture u Internal Level –Physical representation of the database on the computer. –Describes how the data is stored in the database. © Pearson Education Limited 1995, 2005

5 5 Differences between Three Levels of ANSI- SPARC Architecture © Pearson Education Limited 1995, 2005

6 6 Data Independence and the ANSI-SPARC Three-Level Architecture © Pearson Education Limited 1995, 2005

7 7 Database Languages u Data Definition Language (DDL) –Allows the DBA or user to describe and name entities, attributes, and relationships required for the application –plus any associated integrity and security constraints. © Pearson Education Limited 1995, 2005

8 8 Database Languages u Data Manipulation Language (DML) –Provides basic data manipulation operations on data held in the database. u Procedural DML –allows user to tell system exactly how to manipulate data. u Non-Procedural DML –allows user to state what data is needed rather than how it is to be retrieved. u Fourth Generation Languages (4GLs) © Pearson Education Limited 1995, 2005

9 9 Data Models u Object-Based Data Models –Entity-Relationship –Semantic –Functional –Object-Oriented. u Record-Based Data Models –Relational Data Model –Network Data Model –Hierarchical Data Model. © Pearson Education Limited 1995, 2005

10 10 Relational Data Model © Pearson Education Limited 1995, 2005

11 11 Functions of a DBMS u Data Storage, Retrieval, and Update. u A User-Accessible Catalog. u Transaction Support. u Concurrency Control Services. u Recovery Services. © Pearson Education Limited 1995, 2005

12 12 Functions of a DBMS u Authorization Services. u Support for Data Communication. u Integrity Services. u Services to Promote Data Independence. u Utility Services. © Pearson Education Limited 1995, 2005

13 13 Components of Database Manager (DM) © Pearson Education Limited 1995, 2005

14 14 Traditional Two-Tier Client-Server © Pearson Education Limited 1995, 2005

15 15 Three-Tier Client-Server © Pearson Education Limited 1995, 2005

16 16 Data Definition (DDL) u SQL DDL allows database objects such as schemas, domains, tables, views, and indexes to be created and destroyed. u Main SQL DDL statements are: CREATE SCHEMADROP SCHEMA CREATE/ALTER DOMAINDROP DOMAIN CREATE/ALTER TABLEDROP TABLE CREATE VIEWDROP VIEW u Many DBMSs also provide: CREATE INDEXDROP INDEX © Pearson Education Limited 1995, 2005

17 17 CREATE TABLE CREATE TABLE TableName {(colName dataType [NOT NULL] [UNIQUE] [DEFAULT defaultOption] [CHECK searchCondition] [,...]} [PRIMARY KEY (listOfColumns),] {[UNIQUE (listOfColumns),] […,]} {[FOREIGN KEY (listOfFKColumns) REFERENCES ParentTableName [(listOfCKColumns)], [ON UPDATE referentialAction] [ON DELETE referentialAction ]] [,…]} {[CHECK (searchCondition)] [,…] }) © Pearson Education Limited 1995, 2005

18 18 Example 6.1 - CREATE TABLE CREATE TABLE PropertyForRent ( propertyNoPNumberNOT NULL, …. roomsPRoomsNOT NULL DEFAULT 4, rentPRentNOT NULL, DEFAULT 600, ownerNoOwnerNumberNOT NULL, staffNoStaffNumber Constraint StaffNotHandlingTooMuch …. branchNoBranchNumberNOT NULL, PRIMARY KEY (propertyNo), FOREIGN KEY (staffNo) REFERENCES Staff ON DELETE SET NULL ON UPDATE CASCADE ….); © Pearson Education Limited 1995, 2005

19 19 Example 6.1 - CREATE TABLE (note not mandatory – in MS SQL use type not domain) CREATE DOMAIN OwnerNumber AS VARCHAR(5) CHECK (VALUE IN (SELECT ownerNo FROM PrivateOwner)); CREATE DOMAIN StaffNumber AS VARCHAR(5) CHECK (VALUE IN (SELECT staffNo FROM Staff)); CREATE DOMAIN PNumber AS VARCHAR(5); CREATE DOMAIN PRooms AS SMALLINT; CHECK(VALUE BETWEEN 1 AND 15); CREATE DOMAIN PRent AS DECIMAL(6,2) CHECK(VALUE BETWEEN 0 AND 9999.99); © Pearson Education Limited 1995, 2005

20 20 Integrity u Entity –3 th Normal form u Referential –Action taken attempting to update/delete a CK value in parent table with matching rows in child is dependent on referential action specified using ON UPDATE and ON DELETE subclasses: ­CASCADE - SET NULL ­SET DEFAULT- NO ACTION (EX: FOREIGN KEY (ownerNo) REFERENCES Owner ON UPDATE CASCADE) © Pearson Education Limited 1995, 2005

21 21 Views View Dynamic result of one or more relational operations operating on base relations to produce another relation. u Virtual relation that does not necessarily actually exist in the database but is produced upon request, at time of request. © Pearson Education Limited 1995, 2005

22 22 Example 6.4 - Create Vertical View Create view of staff details at branch B003 excluding salaries. CREATE VIEW Staff3 ASSELECT staffNo, fName, lName, position, sex FROM Staff WHERE branchNo = ‘B003’; © Pearson Education Limited 1995, 2005

23 23 Example 6.9 - GRANT Specific Privileges to PUBLIC Give all users SELECT on Branch table. GRANT SELECT ON Branch TO PUBLIC; © Pearson Education Limited 1995, 2005


Download ppt "1 Chapter 2 Database Environment Transparencies © Pearson Education Limited 1995, 2005."

Similar presentations


Ads by Google