1. Trang chủ
  2. » Công Nghệ Thông Tin

Database Design Using Entity-Relationship Diagrams phần 4 ppsx

33 269 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 33
Dung lượng 448,91 KB

Nội dung

English Descriptions We would now like to tighten the grammar that describes how a relationship affects entities using our structural constraints, and to adopt a standard way of stating the relationship. The standard language should appear on the model, or at least with it. Further, using a standard language approach to describe the ER diagrams allows us to not only close the loop with the user in the systems analysis process, but also facilitates feedback and "nails down" the exact meaning of the relationship. In the Chen-like model, the double lines define full participation, as in "automobiles fully participate in the drive relationship." Better yet, the double lines invite us to state the relationship as: Automobiles must be driven by one (and only one) student. The must part comes from the full (mandatory) participation and the one part from the cardinality. The grammar for describing partial or optional relationship for the STUDENT entity to the AUTOMOBILE entity would be: Students may drive one and only one automobile. The may comes from the single line leaving the STUDENT entity box and the "one and only one" part comes from the cardinality. The point is that when expressing the sense of the ER diagrams, one uses the language that conveys what the relationship really means (i.e., students may drive one automobile and automobiles must be driven by one and only one student). A graphic on how to read an ER diagram is presented in Figure 4.3 . Figure 4.3: An ER Diagram of the STUDENT-AUTOMOBILE Database. Translating the Diagram into English Tighter English We strongly recommend that an English sentence accompany each diagram to reinforce the meaning of the figure. Refer to Figure 4.3 . English is often an ambiguous language. The statement that: Automobiles must be driven by one and only one student. actually means that: Automobiles, which are in the database, must be driven by one and only one student. It does not mean that: One particular student drives some automobiles. Another way to put this is: Automobiles must be driven by one and only one student driver. Students may drive one and only one automobile. To relieve ambiguity in the statement of the relationship, we will take the English statement from the relationship we have illustrated, and define four pattern possibilities for expressing our relationship. All binary relationships must be stated in two ways from both sides. As you will see, we will try to stick to the exact pattern match in the following examples, but common sense and reasonable grammar should prevail in cases where the pattern does not quite fit. There is nothing wrong with restating the precise language to make it more clear, but you have to say the same thing! Pattern 1 — x:y::k:1 From the k side, full participation (k = 1 or M): x's, which are recorded in the database, must be related to one and only one y. No x is related to more than one y. Example: Student:Advisor::M:1 Students must be advised by one advisor. or Students, which are recorded in the database, must be advised by one and only one advisor. No student is advised by more than one advisor. The phrase "which are recorded in the database" has proven to be helpful because some database designers tend to generalize beyond the problem at hand. For example, one could reasonably argue that there might be a case where thus-and-so are true/not true, but the point is, will that case ever be encountered in this particular database? The negative statement is often helpful to solidify the meaning of the relationship. Pattern 2 — x:y::k:1 From the k side, partial participation (k = 1 or M): x, but not necessarily all x (which are recorded in the database), may be related to one and only one y. Some x's are not related to a y. x's may not be related to more than one y. Example: Student:Fraternity::M:1 Some students join a fraternity. which becomes: Students, but not necessarily all students (which are recorded in the database), may join a fraternity. Some students may not join a fraternity. Students may not join more than one fraternity. Pattern 3 — x:y::k:M From the k side, full participation (k = 1 or M): x's, which are recorded in the database, must be related to many (one or more) y's. Sometimes it is helpful to include a phrase such as: No x is related to a non y (or) Non x are not related to a y. The negative will depend on the sense of the statement. Example: Automobile:Student::M:N Automobiles are driven by (registered to) many students which means: Automobiles, which are recorded in our database, must be driven by many (one or more) students. There are several ideas implied here. First, we are only talking about vehicles which are registered at this school. Second, in this database, only student cars are registered. Third, if an automobile from this database is driven, it has to be registered and driven by a student. Fourth, the "one or more" comes from the cardinality constraint. Fifth, there is a strong temptation to say something about the y, the M side back to the x, but this should be avoided as this is covered elsewhere in another pattern, and because we discourage inferring other relationships from the one covered. For example, one might try to say here that all students drive cars or all students are related to a vehicle — neither statement is true. Pattern 4 — x:y::k:M From the k side, partial participation (k = 1 or M): x, but not necessarily all x, (which are recorded in the database) may be related to many (zero or more) y's. Some x may not be related to a y. Example: Course:Book::k:M Some courses may require (use) many books. which, restated, becomes: Courses, but not necessarily all courses, (which are recorded in the database) may use many (zero or more) textbooks. Some courses may not require textbooks. Note that due to partial participation (the single lines), the phrase "zero or more," is used for cardinality. If a relationship is modeled with the patterns we have used and then the English sounds incorrect, it may be that the wrong model has been chosen. Generally, the grammatical expression will be most useful in (1) restating the designed database to a naive user, and (2) checking the meaning on the designed database among the designers. The complete version of the English may eventually prove tiresome to a database designer, but one should never lose track of the fact that a statement like "x are related to one y" can be interpreted in several ways unless it is "nailed down" with constraints stated in an unambiguous way. Furthermore, a negation statement may be useful to elicit a requirements definition, although at times the negation is so cumbersome it may be left off entirely. What we are saying is to add the negative or other noncontradictory grammar if it makes sense and helps with requirements elicitation. The danger in adding sentences is that we may end up with contradictory or confusing remarks. Summary of the above Patterns and Relationships Pattern 1: Relationship is x: y ::1 ( full ) :1 Diagramatically shown by Figure 4E Figure 4E: Chen Model of 1(full):1 Relationship — Pattern 1 Pattern 1: Relationship is x: y ::M ( full ) :1 Diagramatically shown by Figure 4F Figure 4F: Chen Model of M(full):1 Relationship — Pattern 1 This is a very common form of a relationship which implies that an instance of ENTITY1 can only exist for one (and only one) of ENTITY2. Pattern 2: Relationship is x: y ::1 (p artial ) :1 Diagramatically shown by Figure 4G Figure 4G: Chen Model of 1(partial):1 Relationship — Pattern 2 Pattern 2: Relationship is x: y ::M (p artial ) :1 Diagramatically shown by Figure 4H Figure 4H: Chen Model of M(partial):1 Relationship — Pattern 2 In this case, some instances in ENTITY1 and ENTITY2 can exist without the relationship to the other entity. Pattern 3: Relationship is x: y ::1 ( full ) :M Diagramatically shown by Figure 4I Figure 4I: Chen Model of 1(full):M Relationship — Pattern 3 Pattern 3: Relationship is x: y ::M ( full ) :N Diagramatically shown by Figure 4J Figure 4J: Chen Model of M(full):N Relationship — Pattern 3 Pattern 4: Relationship is x: y ::1 (p artial ) :M Diagramatically shown by Figure 4K [...]... table Checkpoint 4. 4 1 State the mapping rules that would be used to map Figure 4. 5? Map Figure 4. 5 to a relational database and show some sample data 2 State the mapping rules that would be used to map Figure 4. 8? Map Figure 4. 8 to a relational database and show some sample data Chapter Summary This chapter discussed cardinality and participation ratios in ER diagrams Several examples and diagrams of... ER diagrams using the Chenlike model Follow the methodology and include all English descriptions of your diagrams Exercise 4. 7 Refer to Figure 4. 10 What are the English language statements you can make about the figure? Figure 4. 10 Exercise 4. 8 Refer to Figure 4. 9 Complete the diagram by adding a precise English description of each attribute Map Figure 4. 9 to a relational database Exercise 4. 9 What is... the ER diagrams using the Chen-like model Follow the methodology and include all English descriptions of your diagrams Map the ER diagram to a relational database and include some sample data Exercise 4. 4 Consider a student and advisor database Students have a student number and student name Advisors have names, office numbers, and advise in some major The major that the advisor advises in is designated...Figure 4K: Chen Model of 1(partial):M Relationship — Pattern 4 Pattern 4: Relationship is x:y::M(partial):N Diagramatically shown by Figure 4L Figure 4L: Chen Model of M(partial):N Relationship — Pattern 4 Checkpoint 4. 2 1 Sketch an ER diagram that shows the participation ratios (full/partial) and cardinalities... entity in this case contains the attributes student number, student name, and home telephone number Draw the ER diagrams using the Chen-like model Follow the methodology and include all English descriptions of your diagrams Map the ER diagrams to a relational database Exercise 4. 3 Consider a student database with students and campus organizations Students will have the attributes of student number and student... example, refer to Figure 4. 6 If the STUDENT and COURSE tables have the following data: STUDENT name.first name.last name.mi student_number address Richard Earp W 589 222 2nd St Boris Backer 909 333 Dreistrasse Helga Hogan H 3 84 88 Half Moon Ave Arpan Bagui K 876 33 Bloom Ave Hema Malini 505 100 Livingstone COURSE cname c_number credit_hrs Database COP4710 4 Visual Basic CGS 346 4 3 Elements of Stats STA3023... diagrams using the Chen-like model Follow the methodology and include all English descriptions of your diagrams Map the ER diagram to a relational database and include some sample data Exercise 4. 6 Record the following data in a database: business name, owner, location(s), telephone #(s), delivery truck number, truck capacity, usual route description (e.g., North, West, Central, Lake) Draw the ER diagrams. .. HIST2022 4 Before performing the M3a mapping rule, one must first insure that the primary keys of the entities involved have been established If student_number and c_number are the primary keys of STUDENT and COURSE, respectively, then to map the M:N relationship, we create a relation called ENROLL, as follows: ENROLL c_number student_number COP4710 589 CGS 346 4 589 CGS 346 4 909 STA3023 589 HIST2022 3 84 STA3023... (e.g., Chemistry, CHEM; Biology, BIOL; Computer Science, COMPSC: etc.) Draw the ER diagrams using the Chen-like model Follow the methodology and include all English descriptions of your diagrams Map the ER diagram to a relational database and include some sample data Exercise 4. 5 You want to record the following data in a database: restaurant name and location, employee names and IDs, capacity of restaurant... conceptual design Figure 4. 8 is good for displaying just the entities and the attributes Figure 4. 9 uses the concise form of describing attributes and also includes some steps from above and some sample data For conceptualizing, Figure 4. 8 may be used, and later converted into Figure 4. 9 style for documentation Either figure requires an accompaniment of structured English (step 6) Figure 4. 8: Sample . the designed database to a naive user, and (2) checking the meaning on the designed database among the designers. The complete version of the English may eventually prove tiresome to a database. depicted as in Figure 4. 4 (without attributes). We let the term DORM mean dorm room. Figure 4. 4: An ER Diagram (without Attributes) of a 1:M Relationship In Figure 4. 4 (the Chen-like model),. Pattern 3 Pattern 4: Relationship is x: y ::1 (p artial ) :M Diagramatically shown by Figure 4K Figure 4K: Chen Model of 1(partial):M Relationship — Pattern 4 Pattern 4: Relationship

Ngày đăng: 13/08/2014, 12:21

TỪ KHÓA LIÊN QUAN