Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSS/416 Data Design and Retrieval Workshop 3. CSS/416 Workshop 32 Database Management Systems Terminology Traditional MIS RDBMS Relational Algebra FileTableRelation.

Similar presentations


Presentation on theme: "CSS/416 Data Design and Retrieval Workshop 3. CSS/416 Workshop 32 Database Management Systems Terminology Traditional MIS RDBMS Relational Algebra FileTableRelation."— Presentation transcript:

1 CSS/416 Data Design and Retrieval Workshop 3

2 CSS/416 Workshop 32 Database Management Systems Terminology Traditional MIS RDBMS Relational Algebra FileTableRelation RecordRowTuple FieldColumnAttribute

3 CSS/416 Workshop 33 Database management Systems Relational model Based on 1970 paper by E.F. Codd User sees all data in tables Tables can be combined using “set” operations (linked via columns) Metadata also stored in tables as above Logical design separate from physical implementations

4 CSS/416 Workshop 34 Database Management Systems Functional Dependencies A -> B; A determines B ( A is Determinant ) Partial (PK = AB, B -> C) CustID -> Customer Name

5 CSS/416 Workshop 35 Database Management Systems Keys Derived from entity identifier One or more attributes ( more = composite key) Uniquely determine a row Functionally determine an entire row’s attributes

6 CSS/416 Workshop 36 Database management systems SIDActivityFee 100Skiing200 150Swimming50 175Squash50 200Swimming50 Modification Anomalies (multiple themes) - Can’t insert fact that scuba diving cost $175 - Cant update swimming fee - Delete SID 100=>lose skiing data

7 CSS/416 Workshop 37 Database Normalization Entities should have common theme Stages First Normal form Second Third Others (BCNF, 4 th, 5 th, DK) Impact on referential integrity Denormalize for performance (city, state, zip is classic example)

8 CSS/416 Workshop 38 Database Normalization 1 st normal form – eliminate multi- valued attributes(repeating groups) 2 nd normal – no partial key functional dependencies 3 rd normal – eliminate transitive dependencies

9 CSS/416 Workshop 39 Database Normal Forms Violates first normal – why? Plant Name Eqpt Name Plant Mgr Eqpt Mfgr Mfgr Addr ethyleneFinal cooler, feed heater Jim SmithABC Exchanger 1247 Locust styreneFeed pumpBill GunnXYZ Pumps432 Broadway styreneFeed pumpBill GunnABC Exchanger 1247 Locust

10 CSS/416 Workshop 310 Database Normalization Plant Name Eqpt NamePlant Mgr Eqpt MfgrMfgr Addr ethyleneFinal coolerJim SmithABC Exchanger 1247 Locust ethyleneFeed heaterJim SmithABC Exchanger 1247 Locust styreneFeed pumpBill GunnXYZ Pumps432 Broadway styreneFeed heaterBill GunnABC Exchanger 1247 Locust 1 st Normal satisfied Still violates 2 nd normal– why?

11 CSS/416 Workshop 311 Database Normalization PlantN ame Eqpt name Eqpt MfgrMfgr Addr ethyleneFinal cooler ABC Exchanger1247 Locust ethyleneFeed heater ABC Exchanger1247 Locust styreneFeed pumpXYZ Pumps432 Broadway styreneFeed heater ABC Exchanger1247 Locust PlantN ame Plant Mgr ethyleneJim Smith styreneBill Gunn 2 nd OK but 3 rd ?

12 CSS/416 Workshop 312 Database Normalization PlantN ame Eqpt name Eqpt Mfgr ethyleneFinal cooler ABC Exchanger ethyleneFeed heater ABC Exchanger styreneFeed pumpXYZ Pumps styreneFeed heater ABC Exchanger PlantN ame Plant Mgr EthyleneJim Smith styreneBill Gunn Eqpt MfgrMfgr Addr ABC Exchanger 1247 Locust XYZ Pumps432 Broadway Satisfies 3 rd normal form

13 CSS/416 Workshop 313 Database Normalization BCNF – Every determinant is a candidate key Fourth – Multi-valued dependencies Fifth – Can recombine relations

14 CSS/416 Workshop 314 Database Normalization Domain Key (DK/NF) Provably free from anomalies But no one way to generate this form All constraints follow from domain definitions and keys

15 CSS/416 Workshop 315 Database Normalization Domain Key (DK/NF) “The key, the whole key, and nothing but the key”

16 CSS/416 Workshop 316 Database Design Translating a model to the Database Entities -> tables Establish primary & foreign keys Many-to-many relations ->Junction table Business rules -> triggers, constraints, etc. Surrogate keys Security Typically done with a “CASE” tool

17 CSS/416 Workshop 317 Database Design Has Employee Auto # One-to-one 1 Auto Emp # 1

18 CSS/416 Workshop 318 Database Design Makes Mfgr One-to-many Mfgr # 1 N Equipment

19 CSS/416 Workshop 319 Database Design Has Invoice One-to-many (w/ ID Dependency Inv # 1 N Line Item PK = inv#, item#

20 CSS/416 Workshop 320 Database Design Mfgr Many-to-many Mfgr_Eqpt Equipment MN Mfg #Eqpt ID

21 CSS/416 Workshop 321 Database Design Referred by Member Recursive Member # 1 1

22 CSS/416 Workshop 322 Database Design Member IS-A relationship (Subscriptions) PrintOnline Member#

23 CSS/416 Workshop 323 Database Design Learning teams to implement sample relations for above E-R relationships: 1 to 1 1 to many Many to many 1 to many w/ ID Dependency Recursive IS-A

24 CSS/416 Workshop 324 SQL Two main language components Data definition language (DDL) Data manipulation language (DML)

25 CSS/416 Workshop 325 SQL Data definition language (DDL) Create, alter, drop, etc. Frequently implemented via various CASE tools: Visio, Embarcadero, ERWin, etc. But – also very useful for database administration

26 CSS/416 Workshop 326 SQL Create Statement Create table patient (name varchar2(35) not null, agesmallint, gendervarchar2(1), account_numberinteger not null, primary keyaccount_number)

27 CSS/416 Workshop 327 SQL Select (Projection) Select plantname from equipment Select (Restriction) Select * from equipment where eqpt_name = ‘feed heater’

28 CSS/416 Workshop 328 SQL Select (Selection + projection) Select eqpt_name from equipment where plantname = “styrene” Sorting (Ordering) Select * from manufacturers order by eqpt_mfgr

29 CSS/416 Workshop 329 SQL There are many built in functions Some are called aggregate functions Count Max Avg Etc. Example Select max(age) from dependents

30 CSS/416 Workshop 330 SQL Joins (old syntax) Select m.mfgr_addr from manufacturers m, equipment e where m.eqpt_mfgr = e.eqpt_mfgr and e.plantname = ‘styrene’

31 CSS/416 Workshop 331 SQL Joins (new syntax) Select m.mfgr_addr from manufacturers m inner join equipment e On e.name = m.name where e.plantname = ‘styrene’

32 CSS/416 Workshop 332 SQL Subqueries Select m.mfg_addr from manufacturers m where eqpt_mfgr in (select e.eqpt_name from equipment e)

33 CSS/416 Workshop 333 SQL Insert Insert into equipment values(‘propylene’, ‘feed heater’, ‘ABC Exchanger’) Update Update manufacturers Set address = ‘18 Front Road’ Where mfgr_name = ‘ABC Exchanger’

34 CSS/416 Workshop 334 SQL Delete Delete from equipment Where plant_name = ‘styrene’ And eqpt_name = ‘feed cooler’ How many rows could this delete?

35 CSS/416 Workshop 335 SQL Exercise Create the tables in the design exercise Create a few sample SQL selects, etc.

36 Functions of a Database Application Page 238 Figure 10-1 © 2000 Prentice Hall

37 CSS/416 Workshop 337 CRUD “the first function of a database application is to CRUD views” Create Read Update Delete Page 237

38 CSS/416 Workshop 338 Format or Materialize views “the second function of a database application; the appearance of the content” Page 238

39 CSS/416 Workshop 339 Other database functions Enforce constraints Provide for security and control Execute business logic Page 238

40 E-R Diagram Page 240 Figure 10-3b © 2000 Prentice Hall

41 Relational Design Page 240 Figure 10-3c © 2000 Prentice Hall

42 Relational Design (w/ Surrogate Keys) Page 240 Figure 10-3d © 2000 Prentice Hall

43 Relational Diagram Page 241 Figure 10-3e © 2000 Prentice Hall

44 CSS/416 Workshop 344 View “A structured list of data items (attributes) from the entities or semantic objects defined in the data model” A view can be materialized or formatted as a form or report Page 242

45 CSS/416 Workshop 345 Recordset “the result of an SQL statement” Page 243

46 CSS/416 Workshop 346 CRUD actions on a view Read SELECT CUSTOMER.CustomerID, CUSTOMER.Name FROM CUSTOMER, WORK WHERE CUSTOMER.CustomerID = WORK.CustomerID Page 243

47 CSS/416 Workshop 347 CRUD actions on a view Create INSERT INTO CUSTOMER (CUSTOMER.Name, CUSTOMER.City) VALUES (NewCust.CUSTOMER.Name, NewCust.CUSTOMER.City) Page 244

48 CSS/416 Workshop 348 CRUD actions on a view Update INSERT INTO CUSTOMER (CUSTOMER.Name, CUSTOMER.City) VALUES (NewCust.CUSTOMER.Name, NewCust.CUSTOMER.City) Page 246

49 CRUD actions on a view Delete Cascading deletions depends on relationship cardinality Page 247 Figure 10-6 © 2000 Prentice Hall

50 CSS/416 Workshop 350 Form “a screen display used for data entry and edit” Forms should... reflect the view structure make data associations graphically clear encourage appropriate action Page 248

51 CSS/416 Workshop 351 Forms in a GUI Environment Drop-down list Option buttons in groups Check boxes Page 251

52 GUI controls Page 252 Figure 10-10 © 2000 Prentice Hall

53 CSS/416 Workshop 353 Report Design Reports should... reflect the structure of the underlying view handle implied objects Page 253

54 CSS/416 Workshop 354 Enforcing Constraints Domain Uniqueness Relationship Cardinality 1.1 and 1.N fragments orphans Business Rule triggers Page 256

55 CSS/416 Workshop 355 Security Horizontal Vertical Page 264

56 CSS/416 Workshop 356 Control System of menus Transaction boundaries(Atomic unit of work) Page 265


Download ppt "CSS/416 Data Design and Retrieval Workshop 3. CSS/416 Workshop 32 Database Management Systems Terminology Traditional MIS RDBMS Relational Algebra FileTableRelation."

Similar presentations


Ads by Google