




已阅读5页,还剩27页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
School of Software, CSUModified by Ming Zhao Chapter Four: Database Design Using Normalization Database Processing: Fundamentals, Design, and Implementation 1 School of Software, CSUModified by Ming Zhao Chapter Premise We have received one or more tables of existing data The data is to be stored in a new database QUESTION: Should the data be stored as received, or should it be transformed for storage? 2 School of Software, CSUModified by Ming Zhao How Many Tables? Should we store these two tables as they are, or should we combine them into one table in our new database? 3 School of Software, CSUModified by Ming Zhao Assessing Table Structure 4 School of Software, CSUModified by Ming Zhao Counting Rows in a Table To count the number of rows in a table use the SQL built-in function COUNT(*): SELECTCOUNT(*) AS NumRows FROMSKU_DATA; 5 School of Software, CSUModified by Ming Zhao Examining the Columns To determine the number and type of columns in a table, use an SQL SELECT statement To limit the number of rows retrieved, use the SQL TOP NumberOfRows keyword: SELECTTOP (10) * FROM SKU_DATA; 6 School of Software, CSUModified by Ming Zhao Checking Validity of Assumed Referential Integrity Constraints Given two tables with an assumed foreign key constraint: SKU_DATA (SKU, SKU_Description, Department, Buyer) BUYER(BuyerName, Department) Where SKU_DATA.Buyer must exist in BUYER.BuyerName 7 School of Software, CSUModified by Ming Zhao Checking Validity of Assumed Referential Integrity Constraints To find any foreign key values that violate the foreign key constraint: SELECTBuyer FROM SKU_DATA WHEREBuyer NOT IT (SELECTBuyer FROM SKU_DATA, BUYER WHERESKU_DATA.BUYER =BUYER.BuyerName; 8 School of Software, CSUModified by Ming Zhao Type of Database Updateable database or read-only database? If updateable database, we normally want tables in BCNF If read-only database, we may not use BCNF tables 9 School of Software, CSUModified by Ming Zhao Designing Updateable Databases 10 School of Software, CSUModified by Ming Zhao Normalization: Advantages and Disadvantages 11 School of Software, CSUModified by Ming Zhao Non-Normalized Table: EQUIPMENT_REPAIR 12 School of Software, CSUModified by Ming Zhao Normalized Tables: ITEM and REPAIR 13 School of Software, CSUModified by Ming Zhao Copying Data to New Tables To copy data from one table to another, use the SQL command INSERT INTO TableName command: INSERT INTO ITEM SELECTDISTINCT ItemNumber, Type, AcquisitionCost FROM EQUIPMENT_REPAIR; INSERT INTO REPAIR SELECTItemNumber, RepairNumber, RepairDate, RepairAmmount FROM EQUIPMENT_REPAIR; 14 School of Software, CSUModified by Ming Zhao Choosing Not to Use BCNF BCNF is used to control anomalies from functional dependencies There are times when BCNF is not desirable The classic example is ZIP codes: CUSTOMERS (Number, Name, Street, City, State, Zip) ZIP codes almost never change Any anomalies are likely to be caught by normal business practices Not having to use SQL to join data in two tables will speed up application processing 15 School of Software, CSUModified by Ming Zhao Multivaled Dependencies Anomalies from multivalued dependencies are very problematic Always place the columns of a multivalued dependency into a separtate table (4NF) 16 School of Software, CSUModified by Ming Zhao Designing Read-Only Databases 17 School of Software, CSUModified by Ming Zhao Read-Only Databases Read-only databases are non- operational databases using data extracted from operational databases They are used for querying, reporting and data mining applications They are never updated (in the operational database sense they may have new data imported form time-to- time) 18 School of Software, CSUModified by Ming Zhao Denormalization For read-only databases, normalization is seldom an advantage Application processing speed is more important Denormalization is the joining of data in normalized tables prior to storing the data The data is then stored in non- normalized tables 19 School of Software, CSUModified by Ming Zhao Normalized Tables 20 School of Software, CSUModified by Ming Zhao Denormalizing the Data INSERT INTO PAYMENT_DATA SELECT STUDENT.SID, Name, CLUB.Club, Cost, AmtPaid FROM STUDENT, PAYMENT, CLUB WHERESTUDENT.SID = PAYMENT.SID ANDPAYMENT.Club = CLUB.Club; 21 School of Software, CSUModified by Ming Zhao Customized Tables Read-only databases are often designed with many copies of the same data, but with each copy customized for a specific application Consider the PRODUCT table: 22 School of Software, CSUModified by Ming Zhao Customized Tables PRODUCT_PURCHASING (SKU, SKU_Description, VendorNumber, VendorName, VendorContact_1, VendorContact_2, VendorStreet, VendorCity, VendorState, VendorZip) PRODUCT_USAGE (SKU, SKU_Description, QuantitySoldPastYear, QuantitySoldPastQuarter, QuantitySoldPastMonth) PRODUCT_WEB (SKU, DetailPicture, ThumbnailPicture, MarketingShortDescription, MarketingLongDescription, PartColor) PRODUCT_INVENTORY (SKU, PartNumber, SKU_Description, UnitsCode, BinNumber, ProductionKeyCode) 23 School of Software, CSUModified by Ming Zhao Common Design Problems 24 School of Software, CSUModified by Ming Zhao The Multivalue, Multicolumn Problem The multivalue, multicolumn problem occurs when multiple values of an attribute are stored in more that one column: EMPLOYEE (EmpNumber, Name, Email, Auto1_LicenseNumber, Auto2_LicenseNumber, Auto3_LicenseNumber) This is another form of a multivalued dependency Solution: Like the 4NF solution for multivalued dependencies, use a separate table to store the multiple values 25 School of Software, CSUModified by Ming Zhao Inconsistent Values Inconsistent values occur when different users or different data sources use slightly different forms of the same data value: Different codings: SKU_Description = Corn, Large Can SKU_Description = Can, Corn, Large SKU_Description = Large Can Corn Different spellings: Coffee, Cofee, Coffeee 26 School of Software, CSUModified by Ming Zhao Inconsistent Values Particularly problematic are primary or foreign key values To detect: Use referential integrity check already discussed for checking keys Use the SQL GROUP BY clause on suspected columns SELECT SKU_Description, COUNT(*) AS NameCount FROMSKU_DATA GROUP BYSKU_Description; 27 School of Software, CSUModified by Ming Zhao Missing Values A missing value or null value is a value that has never been provided 28 School of Software, CSUModified by Ming Zhao Null Values Null values are ambiguous: May indicate that a value is inappropriate: DateOfLastChildbirth is inappropriate for a male May indicate that a value is appropriate but unknown DateOfLastChildbirth is appropriate for a female, but may be unknown May indicate that a value is appropriate and known, but has never been entered: DateOfLastChildbirth is appropriate for a female, and may be known but no one has reco
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年执业药师之《西药学专业二》练习题库包附答案详解(预热题)
- 中信银行江门市鹤山市2025秋招数据分析师笔试题及答案
- 兴业银行济南市槐荫区2025秋招笔试专业知识题专练及答案
- 民生银行桂林市七星区2025秋招笔试创新题型专练及答案
- 浦发银行兰州市皋兰县2025秋招笔试性格测试题专练及答案
- 2025年酒、饮料及精制茶制造人员考试黑钻押题附答案详解【预热题】
- 招商银行上海市长宁区2025秋招半结构化面试题库及参考答案
- 家族史考试题目及答案
- 农发行盐城市建湖县2025秋招无领导小组面试案例库
- 农发行黄山市屯溪区2025秋招信息科技岗笔试题及答案
- 桥梁监测方案
- 财务大数据基础-全套课件
- 碳达峰碳中和产业发展调研报告
- 四年级语文下册课外阅读《青铜葵花》导读课 课件(共24张PPT)
- 一般毒性作用
- GB/T 4213-2008气动调节阀
- 小学班队工作原理与实践班队活动的组织与设计课件
- 固体废物采样记录
- 【初中历史】商鞅变法优秀课件31-川教版
- 会议会务需求确认单
- 试生产方案确认表(各单位会签)
评论
0/150
提交评论