Figure 2-28 shows two diagrams (A and B), both of which are legitimate ways to represent that a stock has a history of many prices. Which of the two diagrams do you consider a better way to model this situation and why?
Better Entity-Relationship (E-R) diagram for Stock Price Situation
The one type of diagrammatic representation for stock price situation is shown below:
Diagram A
Explanation:
In the above E-R diagram:
• The “STOCK” is an entity type.
• The entity contains the identifier of “Stock ID”.
• The entity contains the multivalued attribute of “Price History” and composite attributes of “Price” and “Effective Date”.
Another type of diagrammatic representation for stock price situation is shown below:
Diagram B
Explanation:
In the above E-R diagram:
• The “STOCK” is an entity type and the “STOCK PRICE” is a weak entity type.
• The STOCK entity contains the identifier of “Stock ID”.
• The STOCK PRICE entity contains the attributes of “Price” and “Effective Date”.
• The cardinality relationship between the entity STOCK and weak entity STOCK PRICE is mandatory one to mandatory many and it has a weak relationship.
Best Entity-Relationship (E-R) diagram from solution A and solution B:
The better E-R diagram is usually chosen by how the diagram reaches the end users to refer it for their own concept.
• If the organization, the end users have the stock price term then the Diagram B is the better way for modelling this situation.
• This is because,
o The Diagram B expands itself as a two entity types with a relationship between them such as STOCK and STOCK PRICE.
o This will makes the instructors to easily understand the demonstration of an issue.
• But, the Diagram A needs for discussion with end users to get the clear ideas about the attributes present in the STOCK entity.
• In the Diagram B ,
o STOCK PRICE entity instances are added.
o The STOCK PRICE will be occurred for each STOCK entity instances.
o The weak entity is STOCK PRICE that depends on the STOCK entity instance.
Therefore, the “Diagram B” is a best way to model the Entity-Relationship diagram for stock price situation.