tags:

views:

41

answers:

3

Hi all

Trust me, I've put a lot of thought into this problem before asking here, and I think I got a solution, but I'd like to see what you guys can come up with before settling for my own :)

SCENARIO:

In the domain we got 3 entities: A treatment, a beautyshop and an employee. A beautyshop can hire 0 to many employees. Now, a beautysalon has a list of possible treatments it can do for its costumers. Each treatment has a description, a duration and a price. Each employee has a similar list, but each employee can specialize each treatment (different price or duration), add new treatments or "remove" treatments derived from the beautyshop.

.. This seems like a rather common problem to me, so I was hoping someone could come up with something clever :)

So far, Im thinking about letting each treatment have a unique id, and then let the employee list insert treatments by itself which will have the same id as the one from the shop. These employee treatments will then override the shop ones with the same id..

Thanks in advance

A: 

Why do you want to have different treatments with the same ID?

I'd rather set up a "custom treatment" ID.

Charlie Martin
+2  A: 

Are We talking about the objective representation of the problem or about the database representation of the problem? If it's the objective representation, than a specialized treatment should just be a subclass of the generic treatment.

With the relational database representation of the problem, things get a bit harder:

beautyshop ---= employee
beautyshop ---= treatment_type
treatment_type ---= treatment
employee =--= treatment

(---= is one to many, =--= is many to many).

But how do We get a list of treatments available in a beautyshop? We don't. Instead We get a list of treatments available from all beautyshop employees. That said, if a beautyshop has 0 employees, it serves no treatments.

You might use null fields in treatment table to indicate that the particular employee serves this treatment with default properties. If the treatment_type's defaults change for particular beautyshop, then all treatments are updated.

Reef
+1  A: 

I would suggest adding some kind of inheritance/specialization mechanism to the Treatments by adding a parentTreatment reference to the Treatment class. You would have a set of standard Treatments, and each Employee would be able to select and customize them. The BeautySalons wouldn't explicitly store any Treatments, a transient and volatile getAvailableTreatments() method would iterate over the associated Employees and aggregate the parent Treatments of the Treatments offered by each Employee.

Zsolt Török