Presentation is loading. Please wait.

Presentation is loading. Please wait.

+ Relational Model IST210 Class Lecture. + Premiere Products A new company that is going to sells random merchandise via sales representatives You have.

Similar presentations


Presentation on theme: "+ Relational Model IST210 Class Lecture. + Premiere Products A new company that is going to sells random merchandise via sales representatives You have."— Presentation transcript:

1 + Relational Model IST210 Class Lecture

2 + Premiere Products A new company that is going to sells random merchandise via sales representatives You have been hired by HR to develop their employee data requirements What information would you want to keep about each employee?

3 + Premiere Products Now you have been hired by the sales department. They want to know what information they will need to keep track of on sales orders. What information do you think need?

4 + Premiere Products Sales Order

5 + Entity An entity is something of importance to a user that needs to be represented in a database. An entity is a person, place, object, event, or idea for which you want to store and process data An entity represents one theme or topic. In an entity-relationship model (discussed in Chapter 4), entities are restricted to things that can be represented by a single table. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

6 + Relation A relation is a two-dimensional table that has specific characteristics. The table dimensions, like a matrix, consist of rows and columns. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

7 + Characteristics of a Relation 1. Rows contain data about an entity. 2. Columns contain data about attributes of the entity. 3. Cells of the table hold a single value. 4. All entries in a column are of the same kind. 5. Each column has a unique name. 6. The order of the columns is unimportant. 7. The order of the rows is unimportant. 8. No two rows may be identical. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

8 + A Sample Relation EmployeeNumberFirstNameLastName 100MaryAbernathy 101JerryCadley 104AlexCopley 107MeganJackson KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

9 + A Nonrelation Example EmployeeNumberPhoneLastName 100335-6421, 454-9744Abernathy 101251-7789Cadley 104610-9850Copley 107299-9090Jackson Cells of the table hold multiple values KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

10 + A Nonrelation Example EmployeeNumberPhoneLastName 100335-6421Abernathy 101215-7789Cadley 104610-9850Copley 100335-6421Abernathy 107299-9090Jackson No two rows may be identical KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

11 + Terminology Synonyms … TableRowColumn FileRecordField RelationTupleAttribute KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

12 + A Relational Database A relational database is a collection of tables Tables are called relations This term is the basis for the name relational database KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

13

14

15 + A Key A key is one (or more) column(s) of a relation that is (are) used to identify a row. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

16 + Uniqueness of Keys Unique KeyNonunique Key Data value is unique for each row. Consequently, the key will uniquely identify a row. Data value may be shared among several rows. Consequently, the key will identify a set of rows. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

17 + A Composite Key A composite key is a key that contains two or more attributes. For a key to be unique, it must often become a composite key. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

18 + Composite Key Characteristics To identify a family member, you need to know a FamilyID, a FirstName, and a Suffix (e.g., Jr.). The composite key is: (FamilyID, FirstName, Suffix). One needs to know the value of all three columns to uniquely identify an individual. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

19 + A Candidate Key A candidate key is called “candidate” because it is a candidate to become the primary key. A candidate key is a unique key. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

20 + A Primary Key A primary key is a candidate key chosen to be the main key for the relation. If you know the value of the primary key, you will be able to uniquely identify a single row. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

21 + A Surrogate Key A surrogate key is a unique, numeric value that is added to a relation to serve as the primary key. Surrogate key values have no meaning to users and are usually hidden on forms, queries, and reports. A surrogate key is often used in place of a composite primary key. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

22 + Surrogate Key Example If the Family Member primary key is FamilyID, FirstName, Suffix, it would be easier to append and use a surrogate key of FamMemberID. FamilyID, FirstName and Suffix remain in the relation. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

23 + Relationships Between Tables A table may be related to other tables. For example An Employee works in a Department A Manager controls a Project KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

24 + A Foreign Key To preserve relationships, you may need to create a foreign key. A foreign key is a primary key from one table placed into another table. The key is called a foreign key in the table that received the key. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

25 + Foreign Key Example I Employee EMPID FirstName MgrID Manager MgrID MgrName Foreign Key Primary Key KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

26 + Foreign Key Example II Department DeptID DeptName Location Employee EmpID DeptID EmpName Foreign Key Primary Key KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

27 + The Null Value A Null value means that no data was entered. This is different from a zero, space character, or tab character. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

28 + The Problem of the Null Value A Null is often ambiguous. It could mean… The column value is not appropriate for the specific row. The column value is not decided. The column value is unknown. Each may have entirely different implications. KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

29 + Functional Dependency Functional Dependency—A relationship between attributes in which one attribute (or group of attributes) determines the value of another attribute in the same table Illustration… The price of one cookie can determine the price of a box of 12 cookies. (CookiePrice, Qty)BoxPrice KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

30 + Determinants The attribute (or attributes) that we use as the starting point (the variable on the left side of the equation) is called a determinant. (CookiePrice, Qty)BoxPrice Determinant KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

31 + Normalization KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

32 + Normalization Normalization is the transformation of complex user views and data to a set of smaller, stable, and easily maintainable data structures. Normalization creates data that are stored only once on a file. The exception is key fields. The data structures are simpler and more stable. The data is more easily maintained.

33 + Three Steps of Data Normalization The three steps of data normalization are: Remove all repeating groups and identify the primary key. Ensure that all nonkey attributes are fully dependent on the primary key. Remove any transitive dependencies, attributes that are dependent on other nonkey attributes.

34 + Three Steps of Normalization

35 + First Normal Form (1NF) Remove any repeating groups. All repeating groups are moved into a new table. Foreign keys are used to link the tables. When a relation contains no repeating groups, it is in the first normal form.

36 + Second Normal Form (2NF) Remove any partial dependencies. A partial dependency is when the data are only dependent on a part of a key field. A relation is created for the data that are only dependent on part of the key and another for data that are dependent on both parts.

37 + Third Normal Form (3NF) Remove any transitive dependencies. A transitive dependency is when a relation contains data that are not part of the entity. The problem with transitive dependencies is updating the data. A single data item may be present on many records.


Download ppt "+ Relational Model IST210 Class Lecture. + Premiere Products A new company that is going to sells random merchandise via sales representatives You have."

Similar presentations


Ads by Google