Review Applications of Database Systems Applications of Database Systems Theory Practice.

Slides:



Advertisements
Similar presentations
Defined by Edgar Codd in 1970 Defined by Edgar Codd in 1970 Considered ingenious but impractical Considered ingenious but impractical Conceptually simple.
Advertisements

Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
OUTLINE OF THE LECTURE PART I GOAL: Understand the Data Definition Statements in Fig 4.1 Step1: Columns of the Tables and Data types. Step2: Single column.
NORMALIZATION FIRST NORMAL FORM (1NF): A relation R is in 1NF if all attributes have atomic value = one value for an attribute = no repeating groups =
Normalization Dr. Mario Guimaraes. Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints.
Normalisation The theory of Relational Database Design.
Ch 10, Functional Dependencies and Normal forms
Exploring Microsoft Access 2003 Chapter 4 Proficiency: Relational Databases, External Data, Charts, Pivot, and the Switchboard.
Normalization Normalization We discuss four normal forms: first, second, third, and Boyce-Codd normal forms 1NF, 2NF, 3NF, and BCNF Normalization.
Mapping an ERD to a Relational Database To map an ERD to a relational database, five rules are defined to govern how tables are constructed. 1)Rule for.
- relation schema, relations - database schema, database state
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
NORMALIZATION N. HARIKA (CSC).
Relational Data Model Sept. 2014Yangjun Chen ACS Outline: Relational Data Model Relational Data Model -relation schema, relations -database schema,
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to-Relational Mapping.
Logical DB Design 5. 1 CSE2132 Database Systems Week 5 Lecture Logical Database Design.
Web-Enabled Decision Support Systems
11 Chapter 10 Customizing a Database with Macros and Visual Basic for Applications Exploring Microsoft Office Access 2007.
Review: Application of Database Systems
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- Mapping.
Concepts and Terminology Introduction to Database.
CS 405G: Introduction to Database Systems 18. Normal Forms and Normalization.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Normalization for Relational Databases.
SQL Structured Query Language Programming Course.
Functional Dependencies and Normalization for Relational Databases.
How to build ER diagrams
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
1 Functional Dependencies and Normalization Chapter 15.
Normalization Sept. 2012ACS-3902 Yangjun Chen1 Outline: Normalization Chapter 14 – 3rd ed. (Chap. 10 – 4 th, 5 th ed.; Chap. 6, 6 th ed.) Redundant information.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Normalization Sept. 2014ACS-3902 Yangjun Chen1 Outline: Normalization Redundant information and update anomalies Function dependencies Normal forms -1NF,
Normalization.
Review Database Application Development Access Database Development Theory Practice.
Logical Database Design and the Relational Model.
Mapping ER Diagrams to Tables
Database Design Theory CS405G: Introduction to Database Systems Jinze Liu 3/15/20161.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
Database Design The Relational Model Text Ch5
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Relational Database Design by ER- and EER-to-Relational Mapping
Relational Database Design by ER- and EERR-to-Relational Mapping
Relational Database Design by ER-to-Relational Mapping
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
376a. Database Design Dept. of Computer Science Vassar College
Mapping ER Diagrams to Tables
Outline: Relational Data Model
Company Requirements.
Normalization There is a sequence to normal forms:
Review Applications of Database Systems
Normalization Normalization
Outline: Normalization
Relational Database Design by ER- and EER-to-Relational Mapping
Review: Application of Database Systems
1. Explain the following concepts: (a) superkey (b) key
1.(5) Describe the working process with a database system.
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
Mapping an ERD to a Relational Database
Database Design Theory CS405G: Introduction to Database Systems
1. Explain the following concepts of the ER data model:
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
Mapping an ERD to a Relational Database
Database Normalization
Presentation transcript:

Review Applications of Database Systems Applications of Database Systems Theory Practice

Theory Part ER-diagram Referential integrity Relation normalization

ER-diagram Entity types Strong entity type Weak entity type Attributes atomic attributes composite attributes single-valued attributes multi-valued attributes Relationships Cardinality constraints Participation constraints Identifying relationship, recursive relationship

Mapping from ER-diagrams onto relational schemas 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 with respect to 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

Referential Integrity (i)Consider two relation schemas R 1 and R 2 ; ii)The attributes in FK (foreign key) in R 1 have the same domain(s) as the primary key attributes PK (primary key) in R 2 ; the attributes FK are said to reference or refer to the relation R 2. iii)A value of FK in a tuple (record) t 1 of the current state r(R 1 ) either occurs as a value of PK for some tuple t 2 in the current state r(R 2 ) or is null. In the former case, we have t 1 [FK] = t 2 [PK], and we say that the tuple t 1 references or refers to the tuple t 2. Example: Employee(SSN, …, Dno)Dept(Dno, … ) FK

Relationships Window ConsultantID is primary key in Consultant table Relationship line ConsultantID is foreign key in Clients table

Delete Record button Click + to display related records You cannot delete a Consultant without first deleting related Clients

fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno Dname, dnumber, mgrssn, mgrstartdate Dnumber, dlocation Pname, pnumber, plocation, dnum Essn, pno, hours Essn, dependentname, sex, bdate, relationship EMPLOYEE DEPARTMENT DEPT _LOCATIONS WORKS_ON PROJECT DEPENDENT

Updating and constraints delete Delete the WORK_ON tuple with Essn = ‘ ’ and pno = 10. When deleting, the referential constraint will be checked. - The following deletion is not acceptable: Delete the EMPLOYEE tuple with ssn = ‘ ’ - reject, cascade, modify

Cascade deletion – a strategy to enforce referential integrity  ssn  Employee Essn Pno    delete Works-on delete

cascade – a strategy to enforce referential integrity Employee delete ssn supervisor    null  Employee delete ssn supervisor    null  delete not reasonable

Modify (cascade updating) – a strategy to enforce referential integrity  ssn  Employee Essn Pno    delete Essn Pno null   This violates the entity constraint. Works-on

Modify (cascade updating) – a strategy to enforce referential integrity  ssn  Employee delete This does not violate the entity constraint. Department  Dno   chairman Department null Dno   chairman

Normalization We discuss four normal forms: first, second, third, and Boyce-Codd normal forms 1NF, 2NF, 3NF, and BCNF Normalization is a process that “improves” a database design by generating relations that are of higher normal forms. The objective of normalization: “to create relations where every dependency is on the key, the whole key, and nothing but the key”.

Functional Dependencies We say an attribute, B, has a functional dependency on another attribute, A, if for any two records, which have the same value for A, then the values for B in these two records must be the same. We illustrate this as: A  B Example: Suppose we keep track of employee addresses, and we only track one address for each employee. Suppose each employee is identified by their unique employee number. We say there is a functional dependency of address on employee number: employee number  address

EmpNumEmp EmpFnameEmpLname If EmpNum is the PK then the FDs: EmpNum  Emp EmpNum  EmpFname EmpNum  EmpLname must exist.

Transitive dependency Consider attributes A, B, and C, and where A  B and B  C. Functional dependencies are transitive, which means that we also have the functional dependency A  C We say that C is transitively dependent on A through B.

EmpNum Emp DeptNum DeptNname DeptName is transitively dependent on EmpNum via DeptNum EmpNum  DeptName EmpNum  DeptNum DeptNum  DeptName

A partial dependency exists when an attribute B is functionally dependent on an attribute A, and A is a component of a multipart candidate key. InvNumLineNumQtyInvDate Candidate keys: {InvNum, LineNum} InvDate is partially dependent on {InvNum, LineNum} as InvNum is a determinant of InvDate and InvNum is part of a candidate key

First Normal Form We say a relation is in 1NF if all values stored in the relation are single-valued and atomic. 1NF places restrictions on the structure of relations. Values must be simple.

Boyce-Codd Normal Form BCNF is defined very simply: a relation is in BCNF if it is in 1NF and if every determinant is a candidate key. LineNumProdNumQtyInvNum InvNum, LineNumProdNum InvNum, ProdNumLineNum Qty {InvNum, LineNum} and {InvNum, ProdNum} are the two candidate keys.

Second Normal Form A relation is in 2NF if it is in 1NF, and every non-key attribute is fully dependent on each candidate key. 2NF (and 3NF) both involve the concepts of key and non-key attributes. A key attribute is any attribute that is part of a key; any attribute that is not a key attribute, is a non-key attribute. Relations that are not in BCNF have data redundancies A relation in 2NF will not have any partial dependencies

LineNumProdNumQtyInvNum InvNum, LineNumProdNum InvNum, ProdNumLineNum Since there is a determinant that is not a candidate key, InvLine is not BCNF InvLine is not 2NF since there is a partial dependency of InvDate on InvNum Qty InvDate InvNum There are two candidate keys. Qty is the only non- key attribute, and it is dependent on InvNum InvLine is only in 1NF Consider this InvLine table (in 1NF):

LineNumProdNumQtyInvNum InvDateInvNum inv_noline_noprod_noprod_descqty EmployeeDept enamessnbdateaddressdnumberdname

Third Normal Form a relation is in 3NF if the relation is in 1NF and all determinants of non-key attributes are candidate keys That is, for any functional dependency: X  Y, where Y is a non-key attribute (or a set of non-key attributes), X is a candidate key. this definition of 3NF differs from BCNF only in the specification of non-key attributes - 3NF is weaker than BCNF. (BCNF requires all determinants to be candidate keys.) A relation in 3NF will not have any transitive dependencies

EmpNumEmpNameDeptNumDeptName We correct the situation by decomposing the original relation into two 3NF relations. Note the decomposition is lossless. EmpNumEmpNameDeptNumDeptNameDeptNum

student_nocourse_noinstr_no Instructor teaches one course only. Student takes a course and has one instructor. In 3NF, but not in BCNF: {student_no, course_no}  instr_no instr_no  course_no since we have instr_no  course-no, but instr_no is not a Candidate key.

course_noinstr_no student_noinstr_no student_nocourse_noinstr_no BCNF {student_no, instr_no}  student_no {student_no, instr_no}  instr_no instr_no  course_no

Practice Part Forms Reports Queries Macros Tables VBA modules

Tables - table name - attribute name - attribute data type - attribute properties - key

Forms different components: -bound controls -unbound controls -calculated controls -drop-down list box (combo box) -check box -option group -command buttons

Subforms

Subforms are generated using Wizard

Subsubforms

Subforms are generated using Subform/Subreport button

Switchboard is a special form created using Switchboard manager (not covered)

Reports seven sections: - report header - page header - group header - details - group footer -page footer -report footer

Queries different kinds of queries: -select queries -action queries Make-Table query, Delete-Table query Append-Table query, Update query parameter query, unmatched query, find-duplicates query - Crosstab query - total queries Group by Aggregate functions: Count, sum, maximum, minimum, Average

Queries - unmatched queries

Query design grid

SQL statement SelectFirstName, LastName FromEmployees WhereSalary > 40000

Relationships a many-to-many relationship is created by generating two one-to-many relationships.

Macros

Macro groups

VBA modules

Private Sub cmdHistoryForm_Click() 'Display the form DoCmd.OpenForm("Employee"),,,, acFormEdit End Sub Private Sub cmdEmployeeForm_Click() 'Display the form DoCmd.OpenForm("History"),,,, acReadOnly End Sub Private Sub cmdExit_Click() 'Exit the application intResponse = MsgBox("Do you want to exit the Compensation" & _ "application?", vbYesNo + vbCritical, "Exit Application?") If intResponse = vbYes Then Application.Quit acQuitPrompt End If End Sub

Private Sub cmdSummaryReport_Click() 'This procedure defines an SQL query as the record source 'for the "Retirement Summary" report; the SQL statement 'returns all records 'Assign the report name to the strObjectName variable strObjectName = "Retirement Summary" 'Declare a variable to store the SQL statement, define the 'SQL string strSQL = "SELECT Employee.LastName, Employee.FirstName, " & _ "Office.Region, Contribution.PayDate," & _ "Contribution.[401KEmployee], " & _ "Contribution.[401KMatch], Contribution.[401KTotal], " & _ "FROM (Office INNER JOIN Employee ON Office.[OfficeNumber] = " & _ "Employee.[OfficeLocation])" & _ "INNER JOIN Contribution ON Employee.[SSN] = Contribution.[SSN];"