Database Systems

8
COSC 4110 Database Concepts Week 1 Homework Problem 1 NAME JAKE OBRADOVIC Given the file structure shown above (assume flat file world) 1. How many records does the file contain? How many fields per record? The above file has 7 records and 5 fields. The records being 21- 5Z through 31-7P and the files being PROJECT_CODE through PROJECT_BID_PRICE. 2. What problem would you encounter if you wanted to produce a listing by city? How would you solve this problem by altering the file structure? Searching for city name within the MANAGER_ADDRESS field would be very inconvenient since the street name, city, state, and zip code are all grouped together. Altering the file structure into MANAGER_STREET, MANAGER_CITY, MANAGER_STATE, and MANAGER_ZIP would be the most practical way to produce a listing by city alone. 3. If you wanted to produce a listing of the file contents by last name, area code, city, state, or zip code, how would you alter the file structure? The most efficient way to alter the file structure is to break down everything to its most component parts. PROJECT_MANAGER could be broken down into MANAGER_FNAME, MANAGER_LNAME, and MANAGER_INITIAL. MANAGER_PHONE could be broken down into MANAGER_AREACODE and MANAGER_PHONE. And lastly, MANAGER_ADDRESS

description

Chapter Questions and Answers

Transcript of Database Systems

COSC 4110 Database Concepts Week 1 HomeworkProblem 1NAME JAKE OBRADOVIC

Given the file structure shown above (assume flat file world)1. How many records does the file contain? How many fields per record?The above file has 7 records and 5 fields. The records being 21-5Z through 31-7P and the files being PROJECT_CODE through PROJECT_BID_PRICE.2. What problem would you encounter if you wanted to produce a listing by city? How would you solve this problem by altering the file structure?Searching for city name within the MANAGER_ADDRESS field would be very inconvenient since the street name, city, state, and zip code are all grouped together. Altering the file structure into MANAGER_STREET, MANAGER_CITY, MANAGER_STATE, and MANAGER_ZIP would be the most practical way to produce a listing by city alone. 3. If you wanted to produce a listing of the file contents by last name, area code, city, state, or zip code, how would you alter the file structure?The most efficient way to alter the file structure is to break down everything to its most component parts. PROJECT_MANAGER could be broken down into MANAGER_FNAME, MANAGER_LNAME, and MANAGER_INITIAL. MANAGER_PHONE could be broken down into MANAGER_AREACODE and MANAGER_PHONE. And lastly, MANAGER_ADDRESS could be broken down into MANAGER_STREET, MANAGER_CITY, MANAGER_STATE, and MANAGER_ZIP. Dividing everything up makes search flexibility more efficient. 4. What data redundancies do you detect? How could those redundancies lead to anomalies?There is a one to many relationship between PROJECT and MANAGER. Each project is managed by one manager, but one manager can manage more than one project. Holly B. Parker manages projects 21-5Z, 25-9T, and 29-2D. If Hollys name, phone number, or address information needs to be updated or deleted, it would need to be done so 3 times, and they must all be made correctly to avoid anomalies. The same goes for the data on George F. Dorts.

5. Identify and discuss the serious data redundancy problems exhibited by the file structure above.There are multiple records for each client; same redundancy problems as the last file. PROJECT and EMP has a one to many relationship and updating or deleting one of them could lead to inaccurate information if not done correctly. John D. Newson has 2 different phone numbers under EMP_PHONE. Also there are different JOB_CHG_HOUR values for the same CT job code. 6. Looking at the EMP_NAME and EMP_PHONE in the file above what changes would you recommend?I would make a table for client information and a table for project information. I would make EMP_NUM the primary key for the employee table and the foreign key in the project table. This would make the phone number only exist in the employee table and would only be maintained in the employee record. This would get rid of redundant data. 7. Identify the various data sources in the file.The data sources in the file are employee, job, and project. Employee data would be employee numbers, names, and phone numbers. Job data would be job codes and job charge per hour. Project data would be project numbers, names, and hours.8. Given your answer to question 7, what new files should you create to help eliminate the data redundancies found in the file shown above?The new files needed are ones that described in the last question. Each data should be divided into its own relevant field. An employee file would have the employees number, name, address, and phone number. A project field would have the projects name, manager, and budget. A job field would have job codes and billing per hour. Each file would have primary and foreign keys that linked everything together instead of having one file that had everything grouped everything together.

Problem 2 Explain what is meant by the phrase Business Rule. Explain how you may discover business rules.Business rules describe the operations, definitions, and constraints that apply to a company. They can apply to people, processes, behavior, and computing systems. They are made to set standards and help the company reach their goals. You can discover a companys business rules by interviewing, surveying, or watching employees, or by reading the companys policies from a handbook.

Problem 3

Using the relational diagram above, fill out the table below.ENTITYRelationship TypeENTITYBusiness Rules

Region1:M One to manyStoreOne region can have many stores. Each store can only be located in one region.

Store1:M One to manyEmployeeOne store can have many employees. Each employee can only work in one store.

Job1:M One to manyEmployeeOne job can be held by many employees. An employee can only hold one job.

Problem 4Using the INVOICE table structure belowAttribute NameSample ValueSample ValueSample ValueSample ValueSample Value

INV_NUM211347211347211347211348211349

PROD_NUMAA-E3422QWQD-300932XRU-995748GAA-E3422QWGH-778345P

SALE_DATE15-Jan-200815-Jan-200815-Jan-200815-Jan-200816-Jan-2008

PROD_LABELRotary sander0.25-in. drill bitBand sawRotary sanderPower drill

VEND_CODE211211309211157

VEND_NAMENeverFail, Inc.NeverFail, Inc.BeGood, Inc.NeverFail, Inc.ToughGo, Inc.

QUANT_SOLD18121

PROD_PRICE$49.95$3.45$39.99$49.95$87.75

Write the relational schemaDraw its dependency diagram and identify all partial and transitive dependencies. NOTE no repeating groups and an invoice may refer to more than one product.

Problem 5A) For each relational schema identify what level of normal form applies (0NF, 1NF, 2NF, or 3NF). B) Explain your reasoning.

Schema AHospital(Patient, Insurance, Doctor, {Test, Result}) Patient --> Insurance, Doctor Patient + Test --> Result Sample Data Patient Insurance Doctor Test Result Tweety Red Cross Livingston Brain Scan Not Found Tweety Red Cross Livingston Blood work Yes and red Sylvester Red Shield Kilder Cat Scan Yes he is a Cat Sylvester Red Shield Kilder X Rays No broken bones Sylvester Red Shield Kilder Flea check None 3NF, because there are no partial or transitive dependencies.

Schema BInventory(PartNbr, {Warehouse, Location}, QOH, Weight, PartColor) PartNbr --> Weight, PartColor PartNbr + Warehouse -->QOH QOH is Quantity On hand Warehouse --> Location Sample Data PartNbr Warehouse Location QOH Weight PartColor 01 500 NW 135 11.75 Blue 01 600 SW 210 11.75 Blue 01 800 East 192 11.75 Blue 02 500 NW 75 2.50 Red 02 800 East 45 2.50 Red 03 500 NW 290 21.35 Green 03 600 SW 83 21.35 Green1NF, because there are partial dependencies.

Schema C

Ship (BoatId, NbrOfPools, YearMade, Tonage, CompanyId, CompanyName)

The only functional dependencies for this table are:

BoatId --> NbrOfPools, YearMade, Tonage, CompanyId, CompanyName CompanyId --> CompanyName CompanyName --> CompanyId

2NF, because CompanyName and CompanyId are dependent on eachother and both are dependent on BoatId.