Review: Application of Database Systems

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Prentice Hall. All rights reserved.1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2.1: Relational Databases.
Advertisements

Defined by Edgar Codd in 1970 Defined by Edgar Codd in 1970 Considered ingenious but impractical Considered ingenious but impractical Conceptually simple.
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.
Overview Begin 6:00 Quiz15 mins6:15 Review Table Terms25 mins6:40 Short Break10 mins6:50 SQL: Creating Tables60 mins7:50 Break10 mins8:00 Lab – Creating.
Exploring Microsoft Access 2003 Chapter 4 Proficiency: Relational Databases, External Data, Charts, Pivot, and the Switchboard.
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.
© Steven Alter, 2007, all rights reserved Database concepts Difference between a database and the Internet Reason for having a defined data structure Relational.
- relation schema, relations - database schema, database state
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1. Chapter 2: Relational Databases and Multi-Table Queries Exploring Microsoft Office.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access 2007 Committed to Shaping the Next Generation of.
Logical DB Design 5. 1 CSE2132 Database Systems Week 5 Lecture Logical Database Design.
Copyright © 2008 Pearson Prentice Hall. All rights reserved.1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2: Relational Databases.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2: Relational.
Exploring Microsoft Office Access 2010
Review: Application of Database Systems
Designing a Database (Part I) -Identify all fields needed to produce the required information -Group related fields into tables -Determine Each Table’s.
Access Chapter 2: Relational Database Objectives Design data Create tables Understand table relationships Understand data types, key, & field properties.
 Employee (fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno)  Department (dname, dnumber, mgrssn, mgrstartdate) 
Using Microsoft Access 56:150 Information System Design.
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.
Review Database Application Development Access Database Development Theory Practice.
Mapping ER Diagrams to Tables
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
To play, start slide show and click on circle Access 1 Access 2 Access 3 Access 4 Access Access
COP Introduction to Database Structures
Comp 1100 Entity-Relationship (ER) Model
The SQL Database Grammar
Databases Chapter 9 Asfia Rahman.
Chapter 4 Basic SQL.
Chapter 5: Logical Database Design and the Relational Model
CSIS 115 Database Design and Applications for Business
Tables and Their Characteristics
Database Design The Relational Model Text Ch5
CIS 155 Table Relationship
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
Exploring Microsoft Office Access 2007
Outline: Relational Data Model
Company Requirements.
Outline: Database Basics
Review Applications of Database Systems
CS4222 Principles of Database System
Foreign key (FK) is defined as follows:
Review: ACCESS Database Systems
Relational Database Design by ER- and EER-to-Relational Mapping
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Data Types and Field Properties
Answer:  Select queries Parameter queries Cross Tab queries
Relational Database Design by ER- and EER-to-Relational Mapping
Foreign key (FK) is defined as follows:
Relational Database Design by ER- and EER-to- Relational Mapping
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
Microsoft Access Validation Rules, Table Relationships And
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
Lecture 2 Lecturer: awdang aziz MS access
Relational Database Design by ER-to-Relational Mapping
Presentation transcript:

Review: Application of Database Systems ER-diagram Tables and their relationships Application of Database Systems Queries Reports Not covered in midterm

ER-diagram Entity types Strong entity type Weak entity type Relationships Cardinality constraints: 1:1, 1:M, M:N - relationship Participation constraints: mandatory, optional Attributes atomic attributes composite attributes single-valued, multi-valued attributes derived attributes key, partial key, surrogate key, non-key attribute

department employee project dependent works for controls manages works on dependents of controls supervision bdate ssn name lname minit fname sex address salary birthdate relationship number location number of employees startdate hours 1 N supervisor supervisee M degree

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

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

About participation constraints If a relationship is mandatory for an entity set, then if the entity set is on the “many” side of the relationship, then a specification is required to ensure a foreign key has a value, and that it cannot be null setting the ‘required’ property for the FK in MS Access, or NOT NULL constraint in the DDL. N A c d B x y 1

A B c d x y c The “required” property for attribute c is set “yes”.

Setting the required property to Yes

If the entity set is on the “one” side of a relationship, then a check constraint or database trigger can be specified to ensure compliance. c d x y 1 N A B

A B c d x y c A program should be produced to check that any value appearing in c-column in table A must appear at least once in c-column in table B.

Five different ways to create tables Using Table Wizard Using data sheet view Using design view Creating tables with queries Creating tables by importing external data sources

Creating a Table in Design View If you want to create the basic table structure yourself and define all the field names and data types, you can create the table in Design view.

Data Types of Fields Attachment    Files, such as digital photos. Multiple files can be attached per record. This data type is not available in earlier versions of Access. AutoNumber    Numbers that are automatically generated for each record. Currency    Monetary values. Date/Time    Dates and times. Hyperlink    Hyperlinks, such as e-mail addresses. Memo    Long blocks of text and text that use text formatting. A typical use of a Memo field would be a detailed product description. Number    Numeric values, such as distances. Note that there is a separate data type for currency. OLE Object    OLE objects (OLE object: An object supporting the OLE protocol for object linking and embedding. Text    Short, alphanumeric values, such as a last name or a street address. Yes/No    Boolean values.

Located in the lower pane of Table Design View Field Size property Caption property Field Properties can be used to specify characteristics for individual fields Located in the lower pane of Table Design View

Properties (1 of 2) Field size- Adjusts the size of the text field Format- changes the way field is displayed. Does not effect the value. Input Mask- facilitates data entry Caption- Label used for the field Default Value- the automatically entered value

Properties (2 of 2) Validation Rule- Rejects records that do not conform to rules entered. Validation Text- Error returned when validation rule is broken. Required- Forces user to enter in value if selected. Allow Zero Length- Allows text length of 0. Indexed- increases efficiency of search on the field

Examples for Format property Format property for Number data type: #,###.##;(#,###.##)[Red];0,000.00;“Undefined” format for positive number format for 0 format for null-value format for negative number 6,789.77

Examples for Input Mask property Input mask forText data type: !\(999") "000\-0000;0;_ - (204) 888-1234 >!“FJ”\-AA\-00000 – FJ-EA-12048 Input mask for Time data type 99:00:00\ >LL;0;_ - 05:56:00 PM

Create Tables – Consider a Foreign Key Customer ID - Primary Key in Customer Table Customer ID –will only appear in one record - there must only be one unique id per customer Customer ID - Regular Field in Orders Table Customer ID may appear many times – one customer can place many orders Based on the above example: Customer Id is the foreign key in the Orders table This is referred to as a One to Many Relationship

Referential Integrity (i) Consider two relation schemas R1 and R2; The attributes in FK (foreign key) in R1 have the same domain(s) as the primary key attributes PK (primary key) in R2; the attributes FK are said to reference or refer to the relation R2. iii) A value of FK in a tuple (record) t1 of the current state r(R1) either occurs as a value of PK for some tuple t2 in the current state r(R2) or is null. In the former case, we have t1[FK] = t2[PK], and we say that the tuple t1 references or refers to the tuple t2. Example: FK Order(OrderId, …, CustId) Customer(CustId, … )

Working with Multiple Tables – Table Relationships Relationship between two tables The strength of Access is the fact that it is a relational database This means you can have multiple tables and create relationships between each table This helps eliminate redundant data

Working with Multiple Tables – Referential Integrity Enforce Referential Integrity Assures that the references to relationships between data is accurate Established when creating the relationship between two tables

Working with Multiple tables - Cascades Cascade update and cascade delete When active, data changed in one table that is in a relationship will be changed in its related tables Can be set when establishing relationships between tables

cascade – a strategy to enforce referential integrity Employee 123456789 ssn ... delete Works-on Essn Pno 123456789 5 ... delete

cascade – a strategy to enforce referential integrity Employee delete ssn supervisor ... ... 123456789 234589710 null Employee ssn supervisor ... ... 123456789 234589710 null not reasonable delete delete

cascade – a strategy to enforce referential integrity Employee delete ssn supervisor ... ... 123456789 234589710 null Employee ssn supervisor ... ... 123456789 null 234589710 reasonable delete delete

Creating a Table with a Query A make table query retrieves data from one or more tables, and then loads the result set into a new table. That new table can reside in the database that you have open, or you can create it in another database.

Queries different kinds of queries: - select queries - action queries Make-Table query Delete query Append-Table query Update query - Crosstab query - total queries Group by Aggregate functions: count, sum, maximum, minimum, average - one-to-one relationship, one-to-many relationship

Using Query Design View Tables pane Design pane Query Design grid has two panes – the table pane and the design pane Striking the F6 key will toggle you between sections

Select Query Searches associated tables and returns a dataset that matches the query parameters

Specifying Criteria – Currency and Operands Currency amount entered without dollar sign Greater than (>) operand Specify criteria with currency Without the dollar sign With or without the decimal point Use operands such as: Less than and greater than Equal to or not equal to

IS NULL finds only records that have no value IS NOT NULL criteria and partial resulting dataset Is Null criteria and resulting dataset IS NULL finds only records that have no value IS NOT NULL excludes Null value records

Specifying Criteria – And and Or Or Criterion and resulting dataset And criterion and resulting dataset OR finds records that can match one or more conditions AND finds records that must match all criteria specified

Database Analysis Tools SELECT fname FROM customer WHERE lname=“Smith” ORDER BY fname Returns records in the fname field only where the lname field is equal to Smith. Records are sorted in ascending order by first name Clauses - Added to statements to restrict/specify records WHERE clause - Specifies which records to return ORDER BY clause - Specifies sort order

Data Aggregates Use a Totals Query to Group Grouping field Field to be totaled select Location, sum(Balance) where Account, Branch group by Location Organizes query results into groups Only use the field or fields that you want to total and the grouping field

Vid Make Model Colour Kilos Year Price Sold 1 Toyota Celica Red 100000 1994 $15,000.00 Yes 2 Honda Prelude Blue 150000 $18,000.00 No 3 145000 1993 $15,500.00 4 1997 $22,000.00 5 1996   6 7 8 1995

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