This isn't that weird a practice. Those are called GUIDs, or Globally Unique IDs. The idea is that, given a GUID, you can tell exactly what piece of data the id belongs to because it will be unique everywhere. GUIDs are best used when you will be merging different sources of similar data; for example inventory for different stores.
I would do some research and find out as to why this is a common practice in your environment. Maybe it's needed, maybe it's not.
I want to call attention to one of your business rules: Representative is Customer and is Company.
This sounds like a superclass/subclass situation to me, and I think you have the EER diagram well in hand, as far as ER modeling goes. Where things start to get interesting (and a little messy) is when you try to switch over from an ER model (which is abstract and implementation neutral) to a relational model (which is not).
At this point, you'll have to choose between a few well known techniques that make up for the fact that the relational model doesn't incorporate inheritance. You may wish to include this tag in your original question: subtypes
Here are three of the techniques in a nutshell: single table inheritance, class table inheritance, and shared primary key.
Single table inheritance lumps all the subclasses together in one table. Data that does not pertain to a given instance is left NULL.
Class table inheritance has one table for the superclass and one table for each subclass. Generalized data goes in the superclass table, and specialized data goes in the appropriate subclass table.
Shared primary key enforces the one to one nature of the relationships between each subclass and the superclass. It also allows a foreign key elsewhere in the database to reference the superclass without knowing or caring which subclass it belongs to.
For a good treatment of this subject, look up Martin Fowler's treatment on the web.
Edit based on feedback
The question of which ER model is "correct" is usually determined by the database design team by analyzing the subject matter, and coming up with a model that depicts the way it works in "the real world". This presumes that the database is yet to be designed, but the business itself has already been designed, and the business design is not to be changed. Your comment makes me think that you are designing (or redesigning) the business itself, not just the database. If so, then the question is outside the expertise of database design.
To deal more specifically with the questions you asked:
- Is supertype / subtype needed here (since subtype Entities have no unique attributes and since it gives me a headaches)
If there are no attributes that are specialized to the subtypes , then no inheritance (from a data perspective) is needed. So it won't make any difference to the relational design. Don't give yourself headaches. Pick a model that works for your business, and let it go.
- How to implement inheritance with one entity in recursive relationship - if for instance Customer / Representative is in recursive relationship (relational table example needed)
If Customer and Representative are the same entity, give them a common name. One entity with two names is confusing. If they are different entities, rephrase your question. From my answer to question 1, why is implementing inheritance called for?
Are "recursive relationship" and "reflexive relationship" the same thing? If not, please clarify your question.
- Can you give me relational solution (EER to relational) with some examples (like table with data) so I can wrap my mind around it.
That's what I thought I was answering the first time. Fowler's treatment of inheritance/relational issues is available on the web. Here and here.
His examples are about players and cricketers, not customers and representatives, but the issues concerning implementing inheritance (really pseudo inheritance) in a relational system are not case dependent.
Best Answer
Assuming that your
Inquiry
table has aID
column, you can add a column in theAppointment
table which acceptsNULL
and is a foreign key to theInquiry
table. Like so:This way you can lookup the additional details when you need to without duplicating data which is a key component of obtaining third-normal-form.
EDIT
Because an Appointment can be created without an Inquiry I would recommend abstracting the Services, Commodities & Invoices to a separate table which has its own key, which you can then reference from both the Inquiry and Appointment like so:
EDIT based on Comment
As you want to ensure that the
Appointment
will always have the sameOrderDetail
as theInquiry
you could change your model to this:Your other alternative is to implement the check within the logic layer that creates the Appointment and ensure that it only ever creates it using the same Order Detail that the Inquiry has, if the Appointment was based off an Inquiry.