On many to many rela开发者_运维知识库tionship between two entity, there will be a junction entity in between.
My question is, can the junction entity have relationship with another entity? Thank you! (:
Yes. If the new entity is related to the relationship instead of the two parent entities, then it is definitely possible.
One example :Let's say you want to track the payments made for a particular purchase (of a product) by a customer. You will have the three tables.
Customer
----------
Customer_ID,
Customer_Name
Product
-------
Product_id,
Product_name
Purchase (Customer-product-association).
-------------------------------------------
purchase_id,
Customer_ID (FK)
Product_ID (FK)
total_transaction_amt.
Payments (child of purchase)
-------------------------------
Payment_id,
purchase_ID
The Payments table above is in a parent-child relationship with the Purchase table (which is a junction entity). Other relationships (such as many-to-many)are equally valid.
Sure it can. Typically a junction entity will be a "weak" entity, meaning basically that it's dependent on another entity. But it's perfectly legal for that weak entity to have a relationship with another entity.
Say, for example, you have a simple auditing system. The audit is made up of sections. Each section is predefined in an separate table. So you have audit_definition
, which contains the audit definition details, section_type
, which contains the section template, and audit_section_definition
, which connects the two so that you know which sections to use for each audit of that type.
Then you have an audit_instance
table, which contains actual audits of that audit type. To store the section details for that audit instance, you have a section_instance
table. It's entirely conceivable that you would need a link from section_instance
to audit_section_definition
, even though the latter is a junction entity.
精彩评论