3 department employee project dependent works for controls manages works ondependents ofcontrolssupervisionbdatessnnamelnameminitfnamesexaddresssalarybirthdaterelationshipnumberlocationnumber ofemployeesstartdatehours1NsupervisorsuperviseeMdegree
4 Mapping from ER-diagrams onto relational schemas 1. Create a relation for each strong entity type2. Create a relation for each weak entity type3. For each binary 1:1 relationship choose an entity and include theother’s PK in it as an FK4. For each binary 1:n relationship, choose the n-side entity and includean FK with respect to the other entity.5. For each binary M:N relationship, create a relation for the relationship6. For each multi-valued attribute create a new relation7. For each n-ary relationship, create a relation for the relationship
6 About participation constraints If a relationship is mandatory for an entity set, thenif 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 nullsetting the ‘required’ property for the FK in MS Access, orNOT NULL constraint in the DDL.NAcdBxy1
7 ABcdxycThe “required” property for attribute cis set “yes”.
13 Data Types of FieldsAttachment 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 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.
14 Located in the lower pane of Table Design View Field Size propertyCaption propertyField Properties can be used to specify characteristics for individual fieldsLocated in the lower pane of Table Design View
15 Create Tables – Consider a Foreign Key Customer ID - Primary Key in Customer TableCustomer ID –will only appear in one record - there must only be one unique id per customerCustomer ID - Regular Field in Orders TableCustomer ID may appear many times – one customer can place many ordersBased on the above example:Customer Id is the foreign key in the Orders tableThis is referred to as a One to Many Relationship
16 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:FKOrder(OrderId, …, CustId)Customer(CustId, … )
17 Working with Multiple Tables – Table Relationships Relationship between two tablesThe strength of Access is the fact that it is a relational databaseThis means you can have multiple tables and create relationships between each tableThis helps eliminate redundant data
18 Working with Multiple Tables – Referential Integrity Enforce Referential IntegrityAssures that the references to relationships between data is accurateEstablished when creating the relationship between two tables
19 Working with Multiple tables - Cascades Cascade update and cascade deleteWhen active, data changed in one table that is in a relationship will be changed in its related tablesCan be set when establishing relationships between tables
20 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.
22 Using Query Design View Tables paneDesign paneQuery Design grid has two panes – the table pane and the design paneStriking the F6 key will toggle you between sections
23 Select QuerySearches associated tables and returns a dataset that matches the query parameters
24 Specifying Criteria – Currency and Operands Currency amount entered without dollar signGreater than (>) operandSpecify criteria with currencyWithout the dollar signWith or without the decimal pointUse operands such as:Less than and greater thanEqual to or not equal to
25 IS NULL finds only records that have no value IS NOT NULL criteria and partial resulting datasetIs Null criteria and resulting datasetIS NULL finds only records that have no valueIS NOT NULL excludes Null value records
26 Specifying Criteria – And and Or Or Criterion and resulting datasetAnd criterion and resulting datasetOR finds records that can match one or more conditionsAND finds records that must match all criteria specified
27 Database Analysis Tools SELECT fname FROM customerWHERE lname=“Smith”ORDER BY fnameReturns records in the fname field only where the lname field is equal to Smith. Records are sorted in ascending order by first nameClauses- Added to statements to restrict/specify recordsWHERE clause- Specifies which records to returnORDER BY clause- Specifies sort order
28 Data Aggregates Use a Totals Query to Group Grouping fieldField to be totaledselect Location, sum(Balance)where Account, Branchgroup by LocationOrganizes query results into groupsOnly use the field or fields that you want to total and the grouping field