ACFrOgBkmffEP7Pxaegy9IJKZU5cnrXN_cfhfcEyaI6nH327DBlZOncUGy8V9ps1pz4iQ-Rti4gAf1VSXSysaN_VXOJ2V6nJ7q8l3aVPMC1l36R2mALT2RQmYztQ5x2O61jDMyLoQ5-h0IzVfbn3OJrK6TZb_5gG7v38kKOT8g==.pdf

Full Transcript

Data Models for Database System Design Learning Outcomes After completion of this module, you will be able to understand:  categories of data models  Record based data models  E-R Data Model concepts  Entity and Entity Sets  Relationship and Relationship Sets...

Data Models for Database System Design Learning Outcomes After completion of this module, you will be able to understand:  categories of data models  Record based data models  E-R Data Model concepts  Entity and Entity Sets  Relationship and Relationship Sets  Constraints, Keys, Weak and Strong Entity  Reduction of an E-R Schema to Tables The Database Development Process The development of an information system typically takes the following steps known as the Systems Development Life Cycle (SDLC) : 1. Analysis  determine what the user needs, including the conceptual database model 2. Design  design a solution to answer the needs, including the physical database model 3. Programming  develop the necessary database, programs, procedures 4. Implementation  Install and implement the system and train the users. 5. Maintenance  The on-going phase where  bugs are fixed and  enhancements are made to the system  to cop with the ever changing needs of the business. Important In particular, the database design is a critical and integral part of the overall activities Design steps Design steps of developing the database (schema). 1. Real-world to 2. E/R model to 3. Relational schema to 4. Better relational schema to 5. Relational DBMS Data Model A data model is a collection of tools (concepts) for describing  Data  Data relationships  Data semantics  Data constraints Important A proper database design cannot be thrown together quickly by novices. What is required is a practiced and formal approach to  gathering data requirements and  modeling data. This modeling effort requires  a formal approach to the discovery and identification of entities and data elements. Data normalization is a big part of data modeling and database design.  A normalized data model reduces data redundancy and inconsistencies  by ensuring that the data elements are designed appropriately. Definition Database design is the process of  transforming a logical data model into an actual physical database.  Technicians sometimes leap to the physical implementation before producing the model of that implementation.  This is unwise Design sequence A logical data model is required before you can even begin to design a physical database  the logical data model grows out of a conceptual data model Any type of data model begins with the discipline of data modeling. Advantage When databases are built from a well-designed data model the resulting, structures provide  increased value to the organization. The value derived from the data model exhibits itself in the form of  Minimized Redundancy  Maximized Data Integrity  Increased Stability  Better Data Sharing  Increased Consistency  More Timely Access To Data  Better Usability Another benefit of data modeling is  the ability to discover new uses for data. A data model can  clarify data patterns and  potential uses for data that would  remain hidden without the data blueprint provided by the data model. Discovery of such patterns  can change the way your business operates and  can potentially lead to a competitive advantage and  increased revenue for your organization. Components of a Data Model A data model comprises three components: 1. A structural part, consisting of  a set of rules according to which databases can be constructed. 2. A manipulative part, defining  the types of operations that are allowed on the data. 3. A integrity part, possibly a  set of integrity rules, which ensure that the stored data is accurate. Many data models have been proposed over the years.  Some are used to describe  data at the external and conceptual levels,  while others describe  data at the internal level.  Some have greater success than others  in hiding from end-users the underlying details of the physical storage of data. A database schema is usually  expressed using the DDL of a particular DBMS. However, this type of language is too low-level to describe  the data requirements of an organisation in a readily understandable manner People require a higher-level description of the schema  that is organised using the concepts of a particular data model. Data models can be categorized as : a. Object-Based Logical Models b. Record-Based Logical Models c. Semi-Structured Data Model a. Object-Based Logical Models Properties :  DB is structured in variable-length records  Provide flexible structuring capabilities  Allow explicit specifications of data constraints Widely used data models:  Entity-Relationship  Object-Oriented b. Record-Based Logical Models Properties :  DB is structured in fixed-format records of different types Three widely used data models:  Relational  Network  Hierarchical c. Semi-Structured Data Model Data items of the same type can have different sets of attributes Widely used data model:  XML (Extensible Markup Language) Two prominent data models to describe the design of a database at the logical level are:  Entity-Relationship data model  Relational data model Record- Based Logical Model Focuses on describing the data structure and access technique on a database management system. Also describe data at  the conceptual and view levels Used to specify  overall logical structure of the database, and  Provide a higher-level description of the implementation. Named so because  the database is structured in fixed-format records of several types.  Each record type defines a fixed number of fields, or attributes.  Each field is usually of a fixed length (this simplifies the implementation). Record-based models  do not include a mechanism for direct representation of code in the database.  Separate languages associated with the model are used to express  database queries and updates. The three most widely-accepted models : a) Relational b) Network c) Hierarchical. The Relational Model : description  The relational data model was first proposed by Edward Codd in a paper written in 1970  The relational model has a sound theoretical foundation, which is lacking in some of the other models  Data and relationships are represented by a collection of tables  Each table has  a number of columns with unique names, e.g. customer, account. The Network Model  Data are represented by collections of records.  Relationships among data are represented by links.  Organization is that of an arbitrary graph Figure shows a sample network database that is the equivalent of the relational database.(Branch-Account) The Hierarchical Model  Similar to the network model  Organization of the records is as  a collection of trees, rather than arbitrary graphs Figure shows a sample hierarchical database that is the equivalent of the relational database.(Branch-Account). Important The Relational Model does not use pointers or links, but  relates records by the values they contain. This allows a formal mathematical foundation to be defined. Entity-Relationship Data Model In 1976 Peter Chen coined and defined the Entity- relationship model also know as the ER model. The entity-relationship (E-R) model is  a higher-level data model.  It perceives the real world as  consisting of basic object, called entities and relationships among these objects.  E-R model is very useful in mapping  the meanings and interactions of real-world enterprises onto a conceptual schema. Definitions  Entity  Entity Set  Relationship  Relationship Set  Domain  Attribute  Attribute types Entity An entity is an object that exists and is distinguishable from other objects e.g.  specific person, company, event, plant. An entity is represented by a set of attributes, that is  descriptive properties possessed by all members of an entity set e.g.  people have names and addresses Entity Set An entity set is a set of entities of the same type that share the same properties  e.g. set of all persons, companies, trees, holidays Relationship A relationship is an association among several entities. e.g.  A depositor relationship associates a customer with each account he or she has. Example: Hayes depositor A-102 customer entity relationship set account entity Relationship Set The set of all relationships of the same type is called the relationship set. Definition : Relationship Set A relationship set is a mathematical relation among n ≥ 2 entities, each taken from entity sets {(e1, e2, … en) | e1 ЄE1, e2 ЄE2, …, en ЄEn} where (e1, e2, …, en) is a relationship Example: (Hayes, A-102) Є depositor The overall logical structure of a database can be expressed graphically by an E-R diagram: customer-id customer- customer- customer- loan- amount name street city number Domain – the set of permitted values for each attribute Attribute – types of attributes  Simple and composite attributes  Single-valued and multi-valued attributes e.g. multivalued attribute:  phone-numbers, dependent -name  Derived attributes Can be computed from other attributes e.g. age, given date of birth Example: Composit attributes Customer = (customer-id, customer-name,customer-street, customer- city) Loan = (loan-number, amount) E-R Diagrams Symbols  Rectangles represent entity sets.  Diamonds represent relationship sets.  Lines link attributes to entity sets and entity sets to relationship sets.  Ellipses represent attributes  Double ellipses represent multivalued attributes.  Dashed ellipses denote derived attributes.  Underline indicates primary key attributes E-R Diagram With Composite, Multivalued, and Derived Attributes Relationship Set Borrower Descriptive Attribute An attribute can also be property of a relationship set.  For instance, the depositor relationship set between entity sets customer and account may have the attribute access-date Relationship Set Depositor with Descriptive Attributes Degree of a Relationship Set  Refers to number of entity sets that participate in a relationship set. Binary Relationship Sets Relationship sets that involve two entity sets are binary (or degree two). Generally, most relationship sets in a database system are binary.  Most relationships are binary e.g. Suppose employees of a bank may have jobs (responsibilities) at multiple branches, with different jobs at different branches. Ternary Relationship Set Relationship sets may involve more than two entity sets. Relationships between more than two entity sets are rare.  Then there is a ternary relationship set between entity sets employee, job and branch Mapping Cardinalities (Cardinality Constraints) Mapping Cardinalities express  the number of entities to which another entity can be associated via a relationship set. Most useful in describing binary relationship sets. For a binary relationship set the mapping cardinality must be one of the following types: a) One to one b)One to many c) Many to one d)Many to many e.g. Customer and Loan Entity Sets Note:  Some elements in A and B may not be mapped to any elements in the other set Cardinality Constraints Representation We express cardinality constraints by drawing either a  directed line (->), signifying “one,” or  an undirected line (—), signifying “many,”  between the relationship set and the entity set. One-To-One Relationship A customer is associated with at most one loan via the relationship borrower and a loan is associated with at most one customer via borrower One-To-Many Relationship In the one-to-many relationship  a loan is associated with at most one customer via borrower,  a customer is associated with several (including 0) loans via borrower Many-To-One Relationships In a many-to-one relationship  a loan is associated with several (including 0) customers via borrower,  a customer is associated with at most one loan via borrower Many-To-Many Relationship A customer is associated with several (possibly 0) loans via borrower and a loan is associated with several (possibly 0) customers via borrower Roles A relationship might associate several entities from the same underlying entity set,  Entity sets of a relationship need not be distinct. Example 1: works-for relationship The labels “manager” and “worker” are called roles;  they specify how employee entities interact via the works-for relationship set. Roles are indicated in E-R diagrams by labeling the lines that connect diamonds to rectangles. Example2: Reports_To relationship In this case, an additional role indicator (e.g., "supervisor") is used in the diagram to further distinguish the two similar entities worker and supervisor. Role labels are optional, and are used to clarify semantics of the relationship Participation : Participation of an Entity Set in a Relationship Set Total participation Total participation (indicated by double line):  every entity in the entity set participates in at least one relationship in the relationship set e.g.  participation of loan in borrower is total  every loan must have a customer associated to it via borrower Partial participation Partial participation: some entities may not participate in any relationship in the relationship set e.g.  participation of customer in borrower is partial  every customer is not associated with borrower Keys for an entity set Super Key A super key of an entity set is  a set of one or more attributes whose values uniquely determine each entity. Candidate Key A candidate key of an entity set is a minimal super key  Customer-id is candidate key of customer and  account-number is candidate key of account entity. RESULT (ROLLNO, COURSECode) COMPOSITE KEY CANDIDATE KEYS - ROLLNO, ENROLLNO Primary Key Although several candidate keys may exist,  one of the candidate keys is selected to be the primary key to uniquely determine each entity. Reg(RollNo, Name, ….), PKey(RollNo) Course(CourseCode, Title, Sem, Credits) Result(RollNo, CourseCode, Marks), PKey(RollNo, CourseCode) Keys for Relationship Sets The combination of primary keys of the participating entity sets forms a super key of a relationship set  e.g. (customer-id, account-number, access date) is the super key of depositor. (customer-id, loan-number) is the super key of borrower. NOTE: this means a pair of entity sets can have at most one relationship in a particular relationship set. e.g. if we wish to track all access-dates to each account by each customer, we cannot assume a relationship for each access. We can use a multivalued attribute though, one must consider the mapping cardinality of the relationship set when deciding the what are the candidate keys need to consider semantics of relationship set in selecting the primary key in case of more than one candidate key Weak and Strong Entity Sets Strong Entity Set An entity set which have a primary key is referred to as a Strong Entity Set. Weak Entity Set An entity set that does not have a primary key is referred to as a Weak Entity Set.  The existence of a weak entity set depends on the existence of a identifying entity set  It must relate to the identifying entity set via a total, one-to-many relationship set from the identifying to the weak entity set  the Identifying relationship is depicted using a double diamond. Discriminator (Or Partial) Key The discriminator (or partial key) of a weak entity set is  the set of attributes that distinguishes among all the entities of a weak entity set. Primary Key Of A Weak Entity Set The primary key of a weak entity set is formed by the  primary key of the strong entity set  on which the weak entity set is existence dependent, plus  the weak entity set’s discriminator key. Symbols We depict  a weak entity set by double rectangles.  We underline the discriminator of a weak entity set with a dashed line  e.g. payment-number – discriminator of the payment entity set and Primary key for payment – (loan-number, payment- number) Note: The primary key of the strong entity set is not explicitly stored with the weak entity set, since  it is implicit in the identifying relationship Special case If loan-number were explicitly stored, payment could be made a strong entity, but then  the relationship between payment and loan would be duplicated by an implicit relationship  defined by the attribute loan-number common to payment and loan  Loan(loan-number, Amount)  Payment – (loan-number, payment-number,..)  Loan-payment(loan-number,payment- number) - not required Example 2 In a university, a course is a strong entity and a course-offering can be modeled as a weak entity.  The discriminator of course-offering would be semester (including year) and section-number (if there is more than one section).  If we model course-offering as a strong entity we would model course-number as an attribute.  Then the relationship with course would be implicit in the course-number attribute Existence Dependencies If the existence of entity x depends on the existence of entity y, then x is said to be existence dependent on y.  y is a dominant entity (in example below, loan) and  x is a subordinate entity (in example below, payment) If a loan entity is deleted, then all its associated payment entities must be deleted also. Extended E-R Model Features Some aspects of a database may be more aptly expressed by certain extensions of the basic E- model. E-R model support following extended features for more effective database design :  Specialization  Generalization  Higher- and lower-level entity sets  Attribute inheritance  Aggregation Specialization It is a top-down design process and we designate subgrouppings within an entity set that are distinctive from other entities in the set.  These sub groupings become lower-level entity sets that have attributes or participate in relationships  that do not apply to the higher-level entity set.  It is depicted by a triangle component labeled ISA Example 1 : customer “is a” person. The process of designating subgrouppings within an entity set is called specialization. Note: An entity may be specialized on the basis of more than one distinguishing features a) job each employee perform or b) whether employee is permanent or temporary. In this situation an entity may belong to multiple specialization, e.g.  a secretary may be permanent or temporary employee. Example 2 : A bank decides to categories accounts into  savings account with attributes as minimum balance ( may be different for different customers) and interest rate and  checking account with attributes fixed interest rate but overdraft limit, on the basis of requirements. Generalization It is a bottom-up design process –  combine a number of entity sets that share the common features into a higher-level entity set. Example : Database designer might have identified  employee(employee-id, name, street, city) entity set and customer(customer-id, name, street, city) entity set and then  derived higher-level entity set person(name, street, city). This design process is referred to as generalization , which  exists between higher–level and one or more lower-level entity sets. Superclass And Subclass Entity Sets Higher and lower-level entity sets may also be  referred as superclass and subclass entity sets, e.g. person (superclass) and employee and customer (subclass). Important : Specialization and generalization are simple inversions of each other;  they are represented in an E-R diagram in the same way.  The terms specialization and generalization are used interchangeably,  difference is only in approach that has been adopted for design, as top-down or bottom-up. Specialisation stems form single entity set.  It emphasises differences among entities within the entity set by creating lower-level entity sets. Generalisation proceeds from the point that  a number of entity sets share some common features and  synthesices these entity sets into a single higher-level entity set. Higher- and Lower-Level Entity Sets The final outcome of the E-R model is same whether realized by generalisation or specialisation i.e. higher- and lower-level entity sets.  Higher-level entity set : created with attributes and relationships that  apply to all of its lower-level entity sets.  Lower-Level entity sets: created with distinctive attributes that  apply only within a particular lower-level entity set. Example :  employee is a lower-level entity set of person entity and higher-level entity set of  the officer, teller and secretary entity sets Attribute inheritance a lower-level entity set inherits all the attributes and relationship participation of the higher-level entity set to which it is linked. Example : customer and employee entity sets inherit the attributes of person entity set.  A lower-level entity set ( or subclass) also inherits  participation in the relationship sets in which its higher-level entity set (or superclass) participates,  Example: Officer, Teller and Secretary entity sets can participate in works-for relationship set.  Attribute inheritance applies through  all tiers of lower-level entity sets. Single inheritance -  a given entity set may be involved as a lower- level entity set in only one ISA relationship. Multiple inheritance –  an entity set is a lower-level entity set in more than one ISA relationship, resulting structure is a lattice. Design Constraints (specialisation/generalization) For a more realistic enterprise model, A database designer may put certain constraints on a particular specialisation/generalisation. 1. Membership Constraint 2. Disjoint Or Overlapping Constraints 3. Completeness Constraint Constraint type 1 : Membership Constraint One way of adding constraints is to  check which entities can be members of a given lower-level entity set. It can be achieved through constraints a) condition-defined or b) user-defined a) Condition-defined(attribute-defined) constraint Membership for lower-level entity sets is evaluated  on the basis of some condition or predicate, satisfied by entities of the entity set. Example 1: Account entity has an attribute account-type, which will be  used to categorise every account entity to belong to  either savings account or checking account. All customer are members of savings account entity set if account-type = “savings account”. Example 2 : all customers over 65 years are members of senior citizen entity set;  senior-citizen ISA person. Important This type of generalization is also referred as attribute-defined. b) User-defined constraint In User defined,  lower level entity sets are not constrained by a membership condition but  the database user assigns an entity to a particular entity set,  based on certain assumption. Example : after 3 months of employment (training),  bank employees are assigned to one of four,  work team it will not be done automatically. 2. Disjoint Or Overlapping Constraints Second type of constraints relates to whether or not  entities may belong to more than one lower–level entity set within a single generalization. It can be Disjoint or Overlapping generalisation. Disjoint - Disjointness constraint requires  an entity can belong to only one lower- level entity set. Example : an account entity satisfies only one condition for account-type. Overlapping - constraint requires  an entity can belong to more than one lower-level entity set Example 1:  certain managers participates in more than one work team or  an employee may be present in more than one team. Example 2:  an employee can also be a customer of the bank. Note :  Lower-level entity overlap is the default case;  disjointless constraints  must be placed explicitly on generalization or specialization. 3. Completeness - constraint The final constraint is completeness constraint on a generalization/specialization, which specifies whether  a higher level entity set must belong to at least one of the lower level entity set within the generalization/ specialization. Total generalisation or specialisation :  each higher-level entity must belong to one of the lower-level entity sets. Partial generalisation or specialization :  some of higher-level entities need not belong to one of the lower-level entity sets. It is default. Example :  In Account entity generalisation is total because  every account is either a savings account or checking account. (disjoint generalisation)  In work team entity sets, specialization is partial because  lower entity sets contains only those employees who have completed 3 months on the job. (partial overlapping) Insertion / Deletion of Entities Insertion/deletions requirements also follow  from the constraints that apply to specialization or generalisation. a) In case of total completeness constraint (Insertion)  an entity inserted in higher-level entity set  must also be inserted into at least one of the lower-level entity sets. b) In case of condition-defined constraint,  all higher-level entities that satisfies the condition must be inserted into designated lower-level entity set c) In case of deletion,  an entity that is deleted from a higher-level entity set,  should also be deleted from all the associated lower-level entity sets. Aggregation One limitation of E-R model is that it cannot express relationships among relationships. Example Consider the ternary relationship works-on, which we saw earlier. Modification Suppose we want to record managers for tasks performed by an employee at a branch i.e.  managers for (employee, branch, job) combination Alternate 1 : Create quaternary relationship manages. Problem: 1.because binary relationship between employee and manager,  it will not be possible to tell which (branch, job) combinations of an employee are managed by which manager. Alternate 2: Relationships works-on and manages can be combined. Problem 1 :  because some employee, branch, job combinations may not have a manager Problem 2 : Relationship sets works-on and manages represent redundant information.  Every manages relationship corresponds to a works-on relationship,  however,  some works-on relationships may not correspond to any manages relationships.  So we can’t discard the works-on relationship. Final Solution – Aggrigation We can eliminate this redundancy via aggregation. Aggregation : an aggregation is an abstraction through which  relationships are treated as higher-level entities. Advantage Aggregation allows  relationships between relationships and  abstraction of relationship into new entity without introducing redundancy Solution: consider works-on relationship set as a higher level entity set.  Then whole problem can be converted to binary relationship manages between works- on and manager entity set. Final Solution The following diagram represents  an employee works on a particular job at a particular branch.  An Employee, Branch, Job combination may have an associated manager E-R Model Design Decisions Designer has to take decision based on requirements regarding, 1. The use of  an attribute or entity set to represent an object e.g. details of telephone  can be treated as an attribute in customer entity or  telephone can be treated as a separate object 2. Whether a real-world concept is best expressed by  an entity set or a relationship set. Example :  treat Loan as a relationship between Customer and Branch  with Loan# and Amount as Descriptive attribute 3. The use of a ternary relationship versus a pair of binary relationships. 4. The use of a strong or weak entity set. 5. The use of specialization/generalization – contributes to modularity in the design. 6. The use of aggregation –  can treat the aggregate entity set as a single unit  without concern for the details of its internal structure. E-R Diagram for a Banking Enterprise Reduction of E-R Schema to Tables A database that is designed according to an E-R database schema can be represented as set of tables.  For each entity set and for each relationship set in the database,  there is a unique table with separate name. Important Because both the E-R model and relational database model employ similar design principles,  an E-R design can be converted into a relational design. Reduction of an E-R Schema to Tables Primary keys allow  entity sets and relationship sets to be expressed uniformly as tables  which represent the contents of the database. Description A database which conforms to an E-R diagram can be represented by a collection of tables.  there is a unique table  which is assigned the name of the corresponding entity set or relationship set.  Each table has a number of columns generally corresponding to attributes,  which have unique names. Note Converting an E-R diagram to a table format is  the basis for deriving a relational database design from an E-R diagram. Representing Strong Entity Sets as Tables A strong entity set reduces to a table with the same attributes. Table for strong entity Customer : Schema of customer table ATTRIBUT DATA TYPE REMARK CustomerId VARCHAR(12 PRIMARY KEY ) CustomerName Varchar(15) Not Null CustomerStree Varchar(15) t CustomerCity Varchar(15) Table for strong entity Loan : loan-number amount L-11 900 L-14 1500 L-15 1500 L-16 1300 L-117 1000 L-23 2000 L-93 500 ATTRIBUT DATA TYPE REMARK LoanNumber VARCHAR(12) PRIMARY KEY Amount Numeric(10,2) Not Null Representing Relationship Sets as Tables A many-to-many relationship set is represented as a table with columns for  the primary keys of the two participating entity sets, and  any descriptive attributes of the relationship set. Table for relationship set borrower ATTRIBUT DATA TYPE REMARK CustomerId VARCHAR(12 PRIMARY KEY ) LoanNumber VARCHAR(12 PRIMARY KEY ) Representing Weak Entity Sets A weak entity set becomes a table that includes  a column for the primary key of the identifying strong entity set  Table for Weak entity payment : Problem Redundancy of Tables A relationship set linking a weak entity set to the corresponding strong entity set are  many-to-one without descriptive attribute. The primary key of the weak entity set includes  the primary key of strong entity set. Table for relationship Loan-payment : Loan-payment(Loan-number, Payment-number) weak entity Payment : Payment(Loan-number, Payment-number, Payment-date, Payment-amount) Observation Every combination of (Loan-number, Payment-number) in relationship set Loan- payment, will also be in Payment table. So,  Loan-payment table for relationship is redundant and  can easily be dropped without loosing any information. Combination of Tables to improve design 1. For Many-to-one and One-to-many relationship sets In Many-to-one and one-to-many relationship sets that are  total on the many-side can be represented  by adding an extra attribute to the many side,  containing the primary key of the one-side Example : (to avoid table for relationship) Instead of creating a table for relationship account-branch,  add an attribute branch to the entity set account 2. For one-to-one relationship sets  either side can be chosen to act as the “many” side i.e.  extra attribute can be added to either of the tables corresponding to the two entity sets. Problem : Participation is Partial  If participation is partial on the many side,  replacing a table by an extra attribute in the relation corresponding to the “many” side could result in null values  The table corresponding to a relationship set linking a weak entity set to its identifying strong entity set is redundant e.g.:  The payment table already contains the information that would appear in the loan-payment table (i.e., the columns loan-number and payment-number). 3. Composite and Multivalued Attributes Composite attributes are flattened out by creating a separate attribute for each component attribute Example: Given entity set customer with composite attribute name  With composite attributes first-name and last-name  the table corresponding to the entity set has two attributes name.first-name and name.last-name Multivalued Attributes A multivalued attribute M of an entity E is represented by a separate table EM.  Table EM has attributes corresponding to the primary key of E and  an attribute corresponding to multivalued attribute M. Example: Multivalued attribute dependent-names of employee is represented by a table employee-dependent-names( employee- id, dname)  Each value of the multivalued attribute maps to a separate row of the table EM  an employee entity with primary key John and dependents Johnson and Johndotir maps to two rows: (John, Johnson), (John, Johndotir) Representing Specialization as Tables Method 1:  Form a table for the higher level entity  Form a table for each lower level entity set,  include primary key of higher level entity set and local attributes Table Attributes person (name, street, city) customer (name, credit-rating) employee (name, salary) Drawback:  getting information about an employee requires accessing two tables Method 2: Form a table for each entity set with all local and inherited attributes Table attributes person (name, street, city) customer (name, street, city, credit-rating) employee (name, street, city, salary) Drawbacks: attributes street and city may be stored redundantly  for persons who are both customers and employees Representing Generalisation as Tables If specialization is total  table for generalized entity (person) does not required to store information,  can be defined as a “view” relation containing union of specialization tables  But explicit table may still be needed for foreign key constraints Relations Corresponding to Aggregation To represent aggregation create a table containing a) primary key of the aggregated relationship b) the primary key of the associated entity set and c) any descriptive attributes To Represent Aggregation Example: To represent aggregation manages between relationship works-on and entity set manager  create a table manages(employee-id, branch-name, title, manager-name) Important Table works-on is redundant provided  we are willing to store null values for attribute manager-name in table manages  for employees who do not have any manager.

Use Quizgecko on...
Browser
Browser