Page 461 - Computer_Science_F5
P. 461

For example, many students belong
       Computer Science  through Entity-Relationship Diagrams   (d) A many-to-many relationship is
                                                         to the same class.
           (ERD). ERD uses basic graphical symbols
           to show the organisation of entities and
                                                         when one entity from set A can
           their relationships. An important aspect
                                                         be associated with more than one
           of relationships is cardinality which
          FOR ONLINE READING ONLY
           defines how the entities’ data or records
                                                         For example, students are related to
           are related. The common cardinalities         entity from set B and vice versa.
           include one-to-one, one-to-many, many-        multiple teachers, and teachers can
           to-many, and many-to-one relationships.       be associated with multiple students.
           Details for each relationship are outlined
           as follows:                               Cardinality notation symbols
             (a) A one-to-one relationship is when   In cardinality notation symbols, the lines
                one entity from entity set A can be   connecting  entities  appear with  extra
                associated with at most one entity   marks  at  the  end.  These  marks  define
                                                     the cardinality degree. The notations are
                of entity set B and vice versa. For   summarised as s:hown in Figure 8.15.
                example, a school might decide to
                assign one class teacher to precisely                    One
                one class; thus, one teacher manages
                only one class.                                           Many
             (b) A one-to-many relationship is when                      One and only one
                one entity from entity set A can be
                associated with multiple entities of                     Zero or one
                entity set B. Still, an entity from entity
                set B can be associated with at least                   One or many
                one entity in set A. For example, the                    Zero or many
                relationship between a teacher and
                the subjects they teach, where one        Figure 8.15: Cardinality notation
                teacher can teach multiple subjects,
                but only one teacher teaches a given   Generally, these cardinalities  might
                subject.                             apply in an ERD at the entity level. An
                                                     example is the customer order database
             (c) A many-to-one relationship is when   in Figure 8.16, in which a salesperson
                more than one entity from entity set   serves many customers and each  can
                A can be associated with at most     also  place  multiple  orders.  Each  order
                one entity of entity set B. However,  can have only one invoice, but each of
                an entity from entity set B may or  these orders may also include many line
                may not be associated with more  items,  and  each  specifies  the  products
                than one entity from entity set A.   that it contains.

                                                 452
                                                                for Advanced Secondary Schools



     Computer Science Form 5.indd   452                                                     23/07/2024   12:34
   456   457   458   459   460   461   462   463   464   465   466