Presentation is loading. Please wait.

Presentation is loading. Please wait.

Anskaffelse og kravspecifikation UID16_Datamodels.

Similar presentations


Presentation on theme: "Anskaffelse og kravspecifikation UID16_Datamodels."— Presentation transcript:

1 Anskaffelse og kravspecifikation UID16_Datamodels

2 UID16: Data models Kilder UID: Soren Lauesen: User interface design - A software engineering perspective. Addison- Wesley, 2005. Fra kapitel 16. SR: En enkelt slide er fra Soren Lauesen: Software requirements - Styles and techniques. Addison-Wesley, 2002. © 2002, 2005, Pearson Education retains the copyright to the slides from the books, but allows restricted copying for teaching purposes only. It is a condition that the source and copyright notice is preserved on all the material. Bits and pieces for making E/R diagrams A B A B stayID, paymethod

3 Guests Rooms All guests in the database One guest may have several stays. One stay has only one guest One stay may com- prise many rooms. One room may be used for many stays. Stays Boxes with index cards Guest Stay Room 1:m One-to-many relationship m:m Many-to-many relationship A class contains: objects = entities  records Class = entity class  table Entity-relationship data model 3. UID16.1 E/R data model for a hotel

4 Guest Stay Room 1:m One-to-many relationship m:m Many-to-many relationship A class contains: objects = entities  records Class = entity class  table Entity-relationship data model 4. Extra: Some index cards Guest Name: Address: Phone: Passport: John Simpson 456 Orange … 23 558 … Room roomID: bedCount: Type: Price 1: Price 2: 12 2 Double 80 60 Stay Pay by: Date Room 9802 23/812 24/812 24/811 visa E/R model: Lists forbidden on a card Put the date here?

5 5. UID16.2 Attributes and keys name, address, phone, passport stayID, paymethod, roomID, bedCount, type price1, price2 Fields = attributes Key field: Unique identification Guest Stay Room Guests Rooms Stays date

6 6. UID16.3A Resolve m:m with connection class name, address, phone, passport stayID, paymethod roomID, bedCount, type price1, price2 personCount, state (booked | occ | repair) Guest Stay RoomState Room Guests Rooms Stays RoomStates enumeration type date

7 Stay Service Type name, price Guest Stay Room State Room Service Received Service Type date, personCount, state (booked | occupied | repair) name, address1, address2, address3, phone, passport roomID, bedCount, type price1, price2 name, price date, quantity Guest stayID, paymethod, state (booked | in | out | canceled) E.g. Full breakfast 6$, Continental 4$, Telephone... Add to ServiceReceived: serviceType (fullBreakfast | continental |... ) Remove this class? 7. UID16.3B Hotel data model

8 Guest Stay RoomState Room 8. UID16.4 Relational data model Guest Stay RoomState Room stayIDguestIDpaymethod... 980132Cash 980238Visa 980538 roomIDprice1... 1180 1260 1380 stayIDroomIDdatestate... 98011223/8occ 98011124/8occ 98021224/8booked 98011324/8occ guestIDnameaddress1... 32John Si...456 Orange Gr 33Lise Ha...Dysseg... 57 38Yun ChenKirch... 6 Table (relation) Record Foreign key, reference Primary key - artificial Primary key - natural Using the database Who stays in room 11 today 24/8? Which rooms has John Simpson today? Guest Thomson books, what happens? Guest 38 is to be deleted - how? Total amount for room 13? Composite key

9 9. UID16.5 Data sources CarOwner A domain word may become: an entity an attribute a relationship something outside the model printout/computation “noise” Official source text When a car is registrated it gets a license number (shown on the license plate). The Vehicle Office also records the owner’s name and address, civil registration number or company tax file number, the make (producer and model), chassis number, fuel type (gas, diesel,...) and the registration date. The vehicle office sends a registration certificate to the primary owner or user, but it doesn’t show the civil registration number or the company registration number. More than one owner and user may be recorded. ?

10 10. UID16.6 Data dictionary D1:Class: Guest [Notes a, b... refer to guidelines] The guest is the person or company who has to pay the bill. A person has one or more stay records. A company may have none [b, c]. “Customer” is a synonym for guest, but in the database we only use “guest” [a]. The persons staying in the rooms are also called guests, but are not guests in database terms [a]. Examples E1.A guest who stays one night. E2.A company with employees staying now and then, each of them with his own stay record where his name is recorded [d]. E3.A guest with several rooms within the same stay. Attributes 1. name:Text, 50 chars [h] 2. passport:Text, 16 chars [h] Attribute missing in data model Guidelines for classes. Explain: a)Name in the system vs. name in domain b) Relationships to other classes c) Cases where connections are missing d) Concerns when creating or deleting an entity e) Typical and unusual examples

11 11. UID16.6 Data dictionary (cont.) D1:Class: Guest [Notes a, b... refer to guidelines] The guest is the person or company who has to pay the bill. A person has one or more stay records. A company may have none [b, c]. “Customer” is a synonym for guest, but in the database we only use “guest” [a]. The persons staying in the rooms are also called guests, but are not guests in database terms [a]. Examples E1.A guest who stays one night. E2.A company with employees staying now and then, each of them with his own stay record where his name is recorded [d]. E3.A guest with several rooms within the same stay. Attributes 1. name:Text, 50 chars [h] 2. passport:Text, 16 chars [h] Recorded for guests who are obviously foreigners [f, i]. Used for police reports in case the guest doesn’t pay [g]... The name stated by the guest [f]. For companies the official name since the bill is sent there [g]. Longer names exist, but better truncate at registration time than at print out time [g, j]. Guidelines for attributes. Explain: f) From where in the domain do we get the values? g) What are they used for in the domain? h) Possible values i)Special values, e.g. blanks, and when j)Typical and unusual examples

12 12. UID16.7 Network model: Flight routes Chicago ColumbusWashington NewYork AA331 Route City Route: AA331. Mon, Wed ArrDep Chicago10:45 Columbus11:4012:20 Washington13:3014:15 New York15:10 Leg Route Leg City Next 1:1 relation From To attributes?

13 13. UID16.8 Example: Text processor Character Paragraph Document alignment, indentation, spacing... margin, paperSize, headers, columns font, underline... fileName, zoom Section Style ?? Picture ?? Shape ??

14 14. UID16.9 Hierarchies D1 D1.1D1.2D1.3 D1.1.1D1.1.2D1.3.1D1.3.2 HeadQt Dept SubDept Project projID, name, (headqtID, deptID, sDeptID) headqtID, name deptID, name, (headqtID) sDeptID, name, (deptID)

15 D1 D1.1D1.2D1.3 D1.1.1D1.1.2D1.3.1D1.3.2 DeptProject projID, name ? has belongs Dept deptIDnamebelongsTo D1HeadQt D1.1SalesD1 D1.2PersonnelD1 D1.3Development D1 D1.1.1SydneyD1.1 D1.1.2MelbourneD1.1 D1.3.1HardwareD1.3 D1.3.2SoftwareD1.3 15. UID16.9 Hierarchies (cont.)

16 16. UID16.10 Network model: road map Road ?? Section ?? Point ?? Copyright Melway Publishing Pty Ltd. Reproduced from Melway Edition 31 with permission.

17 17. UID16.11 Sub-classes: Internet car broker Customer custID phone1 phone2 Advertisement fromDate toDate make year miles color state price text announce see? Attributes in UML way Class Dealer name address... Private userID cardID expiry Sub-classes E/R solution 1: Constraint - Priv or Dealer Customer Dealer Private custID, phone1... subClass (priv|dealer) custID, userID...custID, name...

18 Customer custID phone1 phone2 Advertisement fromDate toDate make year miles color state price text announce see? Attributes in UML way Class Dealer name address... Private userID cardID expiry Cust&Priv Dealer E/R solution 2: Always space for Private E/R solution 3: Customer may have several roles. All possible attributes. Many nil - depending on role. Customer Role role (private | dealer | reader), userID, name, address, cardID, expiry, custID 18. UID16.11 Sub-classes (cont.)

19 A A 1:m variants: Each A has zero or more Bs Each B has one A Each A has one or more Bs Each B has zero or one A Cardinality : A Each A owns one or more Bs Each B belongs to one A owns belongs Referential integrity B B B A B 1:1 variant: Each A has a B (don’t know about zero) Each B has zero or one A m:m variant Each A has one or more Bs Each B has zero or more As A B 19. UID16.12A Notational variations

20 A B 1:1 1:  UML notation Each A has one or more Bs Each B has one A A B 0:11:99 Each A has one to 99 Bs Each B has zero or one A Stay RoomState 1:m: Move attributes to RoomState and make a 1:m crow’s foot. date, state Stay Room #persons Diamond notation m:m: Make diamond a connection class m m m 1 20. UID16.12A Notational variations (cont.)

21 21. SR2.2F Transformation rules A B C A C A B C A C Two feet facing the same way make one long foot Two feet facing opposite ways make many-to-many Stay Room Stay Room state Room Resolve many- to-many with a connection box

22 Line Class activity Request hour Room hour Room Contract period Activity Class hours Time table User authoriz Authoriz type Room property Property wish Room wish Building wish Building 1:1 0:  1:  1:1 0:  0:1 1:  1:1 0:  1:1 1:  1:1 0:  0:1 1:1 0:  1:1 1:  1:1 0:  1:1 0:  0:1 0:  1:1 0:  1:1 0:1 1:1 0:1 0:  1:  0:  22. UID16.12B UML and broken connectors

23 Line Class activity Request hour Room hour Room Contract period Activity Class hours Time table User authoriz Authoriz type Room property Property wish Room wish Building wish Building 23. UID16.12B Room allocation system in E/R notation

24 24. UID16.14A Normalization and first normal form First normal form: For each primary key, there must be a fixed number of fields of fixed length. Variable length attribute Purpose: Avoid redundancy (same data several places) Find the “true” objects Ensure “table format” Employee qualifications empIDnamedeptIDdeptNameCourses 100Thomson5SalesWindows, Word, Access 101Smith7AccountingWord 102Bunting5SalesWord, Access Course list Employee qualifications empIDnamedeptIDdeptNamecourseIDcourseNameyear 100Thomson5Sales1Windows1996 100Thomson5Sales2Word1996 100Thomson5Sales3Access1997 101Smith7Accounting2Word1996 102Bunting5Sales2Word2000 102Bunting5Sales3Access2001 Fixed length attributes Key repeatedRedundancy Variable number of fields for same key

25 Cure: Move variable-length stuff to a separate table. CoursesTaken empIDcourseIDcourseNameyear 1001Windows1996 1002Word1996 1003Access1997 1012Word1996 1022Word2000 1023Access2001 EmployeeCourseTaken Employees empIDnamedeptIDdeptName 100Thomson5Sales 101Smith7Accounting 102Bunting5Sales 25. UID16.14A Normalization and first normal form (cont.)

26 26. UID16.14B Second normal form Second normal form: First normal form + Non-key fields must depend on entire key. Doesn’t depend on empID CoursesTaken empIDcourseIDcourseNameyear 1001Windows1996 1002Word1996 1003Access1997 1012Word1996 1022Word2000 1023Access2001 Cure: Move fields depending on a partial key to a separate table. CoursesTaken empIDcourseIDyear 10011996 10021996 10031997 10121996 10222000 10232001 Courses courseIDcourseName 1Windows 2Word 3Access CourseCourseTaken

27 27. UID16.14C Third normal form & final model Third normal form: Second normal form + Non-key fields must be independent. Employees empIDnamedeptIDdeptName 100Thomson5Sales 101Smith7Accounting 102Bunting5Sales Depends only on deptID Omit deptID and use deptName as the key? Cure: Move interdependent fields to a separate table. DepartmentEmployee Employees empIDnamedeptID 100Thomson5 101Smith7 102Bunting5 Departments deptIDdeptName 5Sales 7Accounting CourseCourseTaken name year deptName courseName

28 28. UID16.14D Hotel system normalization Rooms roomIDtypebedCountprice1price2 011Double, bath28070 012Single, toilet160 013Double, bath28070 014Single, toilet160 015Double, bath28070 016Single, bath170... Depend only on type Hard to change prices for 400 rooms Rooms roomIDroomType 0111 0123 0131 0143 0151 0164... RoomTypes roomTypedescriptionbedCountprice1price2 1Double, bath28070 2Double, toilet27060 3Single, toilet160 4Single, bath170... Third normal form: Easy to change prices for 8 room types


Download ppt "Anskaffelse og kravspecifikation UID16_Datamodels."

Similar presentations


Ads by Google