Presentation is loading. Please wait.

Presentation is loading. Please wait.

File and data base concepts DB design. Webcast will cover n Databases n Entities n Basic ERD n PK & FK n Basic Database Design.

Similar presentations


Presentation on theme: "File and data base concepts DB design. Webcast will cover n Databases n Entities n Basic ERD n PK & FK n Basic Database Design."— Presentation transcript:

1 File and data base concepts DB design

2 Webcast will cover n Databases n Entities n Basic ERD n PK & FK n Basic Database Design

3 DB: subsystems DB logical structures: hierachical network relational Data Base OSDBM DBMS DDL DML User Application program

4 Views, Schema and Subschemas 2 4 5 7 9 10 12 13 8 15 17 1

5 Types of databases n Hierarchical n Network n Relational n Object-oriented

6 DBMS Has Two Parts n DML: Data Manipulation Language n DDL: Data Definition Language

7 Structured Query Language (SQL) Syntax SELECT col names FROM tablenames WHERE conditions

8 Example Employee nameJob TitleRoom locationExtension Andazola, GenevieveSecretary, Financial Aid1-3082245 Carter, Georgia Secretary, Student Affairs 1-2244716 Durbin,Martina Secretary, Placement Service 1-1104235 Ezikian, Olivia Secretary II,Student Affairs 1-2244714 Hart, Dr. John Director,Placement Services 1-110B4234 Jacobs, Harry M.Director, Financial Aid1-3082244 Jones, Madalena Assistant Director, Student Affairs 1-2244715 Smith, RoseSecretary, Admissions1-1044823 Wells, Dr.Janet Vice-President, Student Affairs 1-2244713 York, RichardDirector, Admissions1-1044822

9 SQL EMPLOYEE (EMPLOYEE_NAME, JOB_TITLE, ROOM_LOCATION, EXTENSION) Ex: get the names of all employees SELECT employe_ename FROM EMPLOYEE; Ex: Get employee information that have location I- 308 Select * FROM EMPLOYEE WHERE ROOM_LOCATION = ‘I-308’;

10 PRIMARY KEY (PK) a unique identifier guarantees that each row of a relation can be uniquely addressed

11 BANK ACCOUNT ( ss#, cust name, cust address) What’s the PK?

12 BANK ACCOUNT( ss#, cuts name, cust address) n SS# can be a PK since it can not repeat in this table What happens if we add cust_account to this table BANK ACCOUNT( ss#, cuts name, cust address, cust-account)

13 n ss# can NOT be a PK if we assume a customer can have multiple accounts For customer smith Table may look like 111-11-1123 smithUBCHK112 111-11-1123 smithUBSAV123 n Note now ss# can NOT be a PK since ss# values are repeating n this violates the definition of PK, it returns two rows!!!!

14 BANK ACCOUNT( ss#, cuts name, cust address, cust-account) n Can cust-account can be a PK? Only if two customers can NOT share the same account, i.e., no joint account

15 BANK ACCOUNT( ss#, cuts name, cust address, cust-account) n PK must be a combination of TWO attributes n In this case SS# and cust-account Should be PK for this relation

16 FK n Relates two tables n Used to maintain INTEGRITY (cross reference) An attribute in ONE table must match values in another table where that attribute is a PK

17 VENDOR and PRODUCT tables VENDOR (Vend_CODE, VEND_CONTACT, VEND_ADDRESS, VEND_PHONE) PRODUCT (PROD_CODE, PROD- DESCRIPTION, PROD_PRICE, PROD_ON_HAND, VEND_CODE) Red implies PK for each table Purple key is PRODUCT table is FK to VENDOR table

18 Entities An object of interest n Person n Place n Event n Concept Ex:StudentOrderCustomer

19 Relationship Exists between entities With entity itself Binary between TWO entities Ternary between THREE entities

20 Relationship among entities Assume: A team can have many players and a player can play for ONLY ONE team TEAM PLAYER TEAM PLAYER TEAM-------  > PLAYER

21 Relationship? STUDENT CLUB Can a student belong to many clubs? Yes then 1:m Can a club have many student members? Yes then 1:n M:N M:N STUDENT CLUB

22 DB Design Concepts ENROLLMENT ( SID, SNAME, SADD,CID,CNAME,GRADE,SEMESTER) how to represent entities and relations

23 112Smith,JUBINSS640MISSp06 112Smith,JUBINSS651DBMSSp06 112Smith,JUBMGMT600LeadershipSp06 113Mary,KTOWSONINSS640MISSp06 113Mary,KTOWSONMGMT600LeadershipBF05 114Chao, PTOWSONINSS640MISBF05 Data Redundancy

24 Remove redundancy STUDENT (SID,SNAME,SADD) CLASS(CID,CNAME) GRADE (SID,CID,GRADE,SEMESTER )

25 DB Design principles NORMALIZATION: 1. represent each ENTITY as a TABLE 2. select the PRIMARY KEY 3. assign entity ATTRIBUTES to FIELDS 4. represent an ONE-TO-MANY relation by a FOREIGN KEY in the MANY table. 5. represent MANY-TO MANY relations as a NEW TABLE. Use FOREIGN KEYS to identify entities involved. The combination of foreign keys is the PRIMARY KEY of the new table. Assign the common attributes to fields.


Download ppt "File and data base concepts DB design. Webcast will cover n Databases n Entities n Basic ERD n PK & FK n Basic Database Design."

Similar presentations


Ads by Google