Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright Kathy S. Schwaig, 20011 MBA 8473 Kathy S. Schwaig Information Technology.

Similar presentations


Presentation on theme: "Copyright Kathy S. Schwaig, 20011 MBA 8473 Kathy S. Schwaig Information Technology."— Presentation transcript:

1 Copyright Kathy S. Schwaig, 20011 MBA 8473 Kathy S. Schwaig Information Technology

2 Copyright Kathy S. Schwaig, 20012 Database Design Steps User Requirements Conceptual Design (E.g. entity-relationship model) Logical Design (E.g. relational model) Physical Design (optimize for performance)

3 Copyright Kathy S. Schwaig, 20013 Database requirements from user User view: part of database important to user Difficult! Why? User Requirements

4 Copyright Kathy S. Schwaig, 20014 Conceptual Design Entity-Relationship Model Entity A “thing” of interest. May be tangible (employee) or intangible (banking transaction). E.g. employee, department, manager, customer. Attributes -- properties or characteristics. Key Each entity must be uniquely identified by an attribute or group of attributes called a key. E.g.: Employee: [EMP#, name, address, phone#]

5 Copyright Kathy S. Schwaig, 20015 Order number Order date Item number QuantityAmount 4340 02/08/94 1583 2 1740 Key field This record describes the entity called ORDER and its attributes. The specific values for order number, order date, item number, quantity, and amount for this particular order are the fields for this record. Order number is the key field because each order is assigned a unique identification number. Order : [Order number, order date, item number, quantity, amount] Attributes ENTITY = ORDER

6 Copyright Kathy S. Schwaig, 20016 An association between entities. E.g. Managers manage Employees Cardinalities indicate the number of each entity that may participate in the relationship. One to one (1:1) One to many (1:N) Many to many (N:M) M:N relationships may have relationship attributes. E.g. Employees assigned-to Projects:[length-of-time] N : M Relationship

7 Copyright Kathy S. Schwaig, 20017 Entity- Relationship Diagram Each entity represented by a rectangle. Each relationship represented by a diamond. Attributes shown in ovals. Cardinalities next to entities

8 Copyright Kathy S. Schwaig, 20018 E-R Diagram StudentCourse SSNname address gradeCourse# description assigned to NM

9 Copyright Kathy S. Schwaig, 20019 You have been asked to create a database for a small consulting company. The company wants to keep track of which employees are assigned to which project and what dates they start and stop working on them. An employee can work on more than one project at a time (as any MBA student knows). You also need to keep track of which client sponsors which project(s). Each project usually requires a set of skills so you need to know what skills an employee has and when he or she obtained them. Employees are encouraged to find clients and receive extra compensation for doing so. Consulting Company Database

10 Copyright Kathy S. Schwaig, 200110 Project Employee Emp# Client Client-Id sponsors finds start-date end-date Project# has date acquired Skill requires Skill- name M N M N l N M N 1 N assigned to

11 Copyright Kathy S. Schwaig, 200111 Entities Employee : [Emp#, name, address, dob, hourly-rate] Client : [Client-Id, name, phone, date-signed] Skill : [Skill-name, description] Project : [Project#, name, date-began, date-completed] Consulting Company Database Entity-Relationship Model

12 Copyright Kathy S. Schwaig, 200112 Relationships Employee finds Client 1 : N Client sponsors Project 1 : N Employee has Skill : [date-acquired] N : M Project requires Skill N : M Employee assigned-to Project : [start-date, end-date] N : M Consulting Company Database Entity-Relationship Model (cont’d)

13 Copyright Kathy S. Schwaig, 200113 Relational Data Model One basic construct: the relation. Relations represent both entities and relationships. Data Manipulation Language: English-like. Dominant database structure. DB2 by IBM ACCESS by Microsoft ORACLE

14 Copyright Kathy S. Schwaig, 200114 Translate E-R Model into Relational Model Each entity represented by an (entity) relation N:M relationship represented by a separate (relationship) relation Key is concatenation (joining together) of entity keys. Relationship attributes are non keys. 1:N relationship represented by foreign key, i.e. key of entity on “1” side appears as non key in relation for the entity on the “N” side.

15 Copyright Kathy S. Schwaig, 200115 Example: Student-Course Design a database to keep track of what courses a student takes and the grade he or she receives. Entities: Student: [SSN, name, address] Course: [Course-Id, description] Relationships:Student takes Course: [grade] N : M

16 Copyright Kathy S. Schwaig, 200116 Student Relation Course Relation

17 Copyright Kathy S. Schwaig, 200117 Takes Relation

18 Copyright Kathy S. Schwaig, 200118 Employee : [Emp#, name, address, dob, hourly-rate] Client : [Client-Id, name, phone, date-signed, emp#] Project : [Project#, name, date-began, date-completed, client-id] Skill : [Skill-name, description] Has-skill : [Emp#, Skill-name, date-acquired] Requires : [Project#, Skill-name] Assigned : [Emp#, Project#, start-date, end-date] Consulting Company Relational Model

19 Copyright Kathy S. Schwaig, 200119

20 Copyright Kathy S. Schwaig, 200120

21 Copyright Kathy S. Schwaig, 200121 SQL Query SELECTcolumns FROMtables WHEREconditions ORDER BYcolumns What date was the project called “Metro” completed? Select date-completed From project Where name=‘Metro’ Answer: 1 Mar 1999

22 Copyright Kathy S. Schwaig, 200122 SQL Query What is the name of the client who sponsors the project called “Pontiac”? Select client.name From client, project Where project.name=‘Pontiac’ and project.client-id=client.client-id Answer: Ed Edwards

23 Copyright Kathy S. Schwaig, 200123 What skills are required for the project called “Virtual Courtyard”? SELECT requires.skill-name FROM requires, project WHERE project.name= ‘Virtual Courtyard’ and requires.project# = project.project# Answer: Electronic Commerce Data Mining SQL Query


Download ppt "Copyright Kathy S. Schwaig, 20011 MBA 8473 Kathy S. Schwaig Information Technology."

Similar presentations


Ads by Google