0
0
LLDsystem_design~20 mins

Relationships (association, aggregation, composition) in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of Relationships in System Design
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identify the type of relationship in a library system

In a library system, a Book can be borrowed by many Members, and a Member can borrow many Books. What type of relationship is this?

AAssociation
BAggregation
CInheritance
DComposition
Attempts:
2 left
💡 Hint

Think about whether the objects can exist independently.

Architecture
intermediate
2:00remaining
Choose the correct relationship for a car and its engine

A Car has an Engine. The engine can exist independently and can be replaced. What is the correct relationship between Car and Engine?

ADependency
BComposition
CAssociation
DAggregation
Attempts:
2 left
💡 Hint

Consider if the engine can exist without the car.

scaling
advanced
3:00remaining
Impact of composition on object lifecycle in a social media app

In a social media app, a UserProfile contains ProfilePicture as a part of it. If the UserProfile is deleted, the ProfilePicture is also deleted. What is the impact of this composition relationship on system design when scaling?

AIt allows independent scaling of ProfilePicture storage.
BIt simplifies cleanup but requires careful cascading deletes in the database.
CIt requires ProfilePicture to be cached separately for performance.
DIt means ProfilePicture can be shared among multiple UserProfiles.
Attempts:
2 left
💡 Hint

Think about ownership and lifecycle dependency.

tradeoff
advanced
3:00remaining
Choosing between aggregation and composition for a shopping cart system

In a shopping cart system, a ShoppingCart contains multiple Items. Items can exist without the cart and can be added to multiple carts. Which relationship is best and why?

AAggregation, because items can exist independently and be shared.
BComposition, because items belong exclusively to one cart.
CAssociation, because items and carts have no ownership.
DInheritance, because items are a type of cart element.
Attempts:
2 left
💡 Hint

Consider if items can be shared or must be owned exclusively.

component
expert
4:00remaining
Designing a document editor with embedded images: relationship choice

You are designing a document editor where a Document contains multiple EmbeddedImages. EmbeddedImages cannot exist outside the document and are deleted when the document is deleted. However, images can be large and stored separately for performance. Which relationship best models this scenario and why?

ADependency, because images are only used temporarily during editing.
BAggregation, because images are stored separately and can exist independently.
CComposition, because EmbeddedImages lifecycle depends on Document.
DAssociation, because images and documents are loosely connected.
Attempts:
2 left
💡 Hint

Think about ownership and lifecycle dependency despite storage separation.