In a system where users can belong to groups and share expenses, which of the following best describes the relationship between User, Group, and Expense classes?
Think about how users collaborate in groups and how expenses are shared.
Users can be members of multiple groups, groups contain multiple users, and expenses are linked to groups and paid by users.
Which attribute best represents the payer of an Expense in the Expense class?
Consider how to uniquely identify the payer without duplicating user data.
Using payer_id links the expense to the User uniquely and avoids data duplication.
When a Group contains thousands of Users and hundreds of Expenses, which design choice helps maintain performance and scalability?
Think about memory usage and data duplication when handling large numbers.
Storing only User IDs reduces memory usage and allows lazy loading of User details, improving scalability.
Where should the details of how an Expense is split among Users be stored for best design?
Consider separation of concerns and flexibility for future changes.
A separate Split class cleanly models the many-to-many relationship and allows flexible queries.
Estimate the approximate storage needed if each User object requires 1KB, each Group object 2KB, and each Expense object 0.5KB. Ignore overhead and indexes.
Calculate total size by multiplying counts by sizes and summing.
Users: 1,000,000 * 1KB = 1,000,000 KB = ~1GB
Groups: 100,000 * 2KB = 200,000 KB = ~0.2GB
Expenses: 10,000,000 * 0.5KB = 5,000,000 KB = ~5GB
Total ~6.2GB rounded to 6.5GB.