Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to the database systems (1)

Similar presentations


Presentation on theme: "Introduction to the database systems (1)"— Presentation transcript:

1 Introduction to the database systems (1)
- What is a database - The main characters of a database - The basic database design method - The entity-relationship data model for application modeling Concepts and Architecture - Database schema, Schema evolution, Database state - Working process with a database system - Database system architecture - Data independence concept Sept. 2004 Yangjun Chen

2 Data modeling using ER-model (2) - Entity types - strong entities
- Entity-relationship model - Entity types - strong entities - weak entities - Attributes - attribute classification - Relationships among entities - Constraints - cardinality constraints - participation constraints - ER-to-Relation-mapping Sept. 2004 Yangjun Chen

3 - static hashing & dynamic hashing - hash function
Hashing technique (3) - external hashing - static hashing & dynamic hashing - hash function - mathematical function that maps a key to a bucket address - collisions collision resolution scheme - open addressing - chaining - multiple hashing - linear hashing Sept. 2004 Yangjun Chen

4 - root, internal, leaf, subtree - parent, child, sibling
Multi-level index (4) - tree - root, internal, leaf, subtree - parent, child, sibling - balanced, unbalanced - b+-tree - splits on overflow; merge on underflow - in practice it is usually 3 or 4 levels deep - search, insert, delete algorithms Sept. 2004 Yangjun Chen

5 Data modeling using Relational model Relational algebra (5)
- Relational Data Model - relational schema, relations - database schema, database state - integrity constraints and updating - Relational algebra - select, project, join, cartesian product - set operations: union, intersection, difference - division Sept. 2004 Yangjun Chen

6 - select-from-where clause - group by, having, order by - update
SQL (6) - DDL - creating schemas - modifying schemas - DML - select-from-where clause - group by, having, order by - update - view Sept. 2004 Yangjun Chen

7 ER-to-Relation mapping (7)
General process 1. Create a relation for each strong entity type 2. Create a relation for each weak entity type 3. For each binary 1:1 relationship choose an entity and include the other’s PK in it as an FK 4. For each binary 1:n relationship, choose the n-side entity and include an FK wrt the other entity. 5. For each binary M:N relationship, create a relation for the relationship 6. For each multi-valued attribute create a new relation 7. For each n-ary relationship, create a relation for the relationship Sept. 2004 Yangjun Chen

8 ER-to-Relation mapping (7)
4 choices (for handling is-a relationship): 1. Create separate relations for the supertype and each of the subtypes. 2. Create relations for the subtypes only - each contains attributes from the supertype. 3. (disjoint subtypes) Create only one relation - includes all of the attributes for the supertype and all for the subtypes, and one discriminator attribute. 4. (overlapping subtypes) Create only one relation - includes all of the attributes for the supertype and all for the subtypes, and one logical discriminator attribute per subtype. Sept. 2004 Yangjun Chen

9 - Inference rules for function dependencies - 1NF - First Normal Form
Normalization (8) - Function dependency We say a functional dependency exists between the attributes X and Y: X  Y, if, whenever a tuple exists with the value x for X, it will always have the same value y for Y. - Inference rules for function dependencies - 1NF - First Normal Form The domain of an attribute must only contain atomic values. Sept. 2004 Yangjun Chen

10 - 2NF - Second Normal Form A relation schema is in 2NF if
Normalization (8) - 2NF - Second Normal Form A relation schema is in 2NF if (1) it is in 1NF and (2) every non-key attribute must be fully functionally dependent on the primary key. - 3NF - Second Normal Form A relation schema is in 3NF if (1) it is in 2NF and (2) each non-key attribute must not be fully functionally dependent on another non-key attribute (there must be no transitive dependency of a non-key attribute on the PK) Sept. 2004 Yangjun Chen

11 (a) X is a superkey of R, or (b) A is a prime attribute of R.
Normalization (8) - Boyce Codd Normal Form, BCNF Consider a different definition of 3NF, which is equivalent to the previous one. A relation schema R is in 3NF if, whenever a function dependency X  A holds in R, either (a) X is a superkey of R, or (b) A is a prime attribute of R. Removing (b), we have the definition for BCNF. Sept. 2004 Yangjun Chen

12 Lossless Join (9) Lossless join - Decomposition of a relation schema
Emp_PROJ SSN PNUM hours ENAME PNAME PLOCATION F = {SSN  ENAME, PNUM  {PNAME, PLOCATION}, {SSN, PNUM}  hours} R1 R2 SSN ENAME PNUM PNAME PLOCATION R3 SSN PNUM hours Lossless join Sept. 2004 Yangjun Chen

13 - Matrix transformation to check the lossless join property
- Matrix for a decomposition A1 SSN A2 ENAME A3 PNUM A4 PNAME A5 PLOCATION A6 hours b11 b21 b31 b12 b22 b32 b13 b23 b33 b14 b24 b34 b15 b25 b35 b16 b26 b36 R1 R2 R3 - Matrix transformation to check the lossless join property Sept. 2004 Yangjun Chen

14 Lossless Join (9) SSN  ENAME SSN ENAME R1 R2 R3 a1 a2 b13 b14 b15 b16
Sept. 2004 Yangjun Chen

15 Lossless Join (9) PNUM  {PNAME, PLOCATION} PNUM PNAME PLOCATION R1 R2
b13 b14 b15 b16 b21 b22 a3 a4 a5 b26 a1 a2 a3 a4 a5 a6 Sept. 2004 Yangjun Chen

16 Deductive Databases (10)
- A deductive database can be defined as an advanced database augmented with an inference system. - well-formed formulas - clause and Horn-clause - Bottom-up and top-down evaluation of non-recursive queries. - Naive and semi-naive evaluation of recursive queries. Sept. 2004 Yangjun Chen

17 Hierarchical Databases (11)
- Hierarchical schema - PCR relationship - PCR occurrence and hierarchical occurrence - Virtual PCR - Data definition and data manipulation in hierarchical schema Sept. 2004 Yangjun Chen


Download ppt "Introduction to the database systems (1)"

Similar presentations


Ads by Google