11

I'm creating a conceptual diagram [yes, I know I've included attributes and keys - but this is just for me to consolidate what I'm doing whilst learning] -- so please treat it as Conceptual with the focus on Relationships and tables and not how to diagram ;)

My mind hurdle is: I'm trying to ascertain the best way to model the Profile, Location and Organization relationships.

First of all, RULES:

  • One or more Profile's can be a Member/Friend of one or more Organizations; and vice versa.
  • One or more Profile's can be a Member/Friend of other Profiles.
  • One or more Organization's can be a Member/Friend of other Organizations.

enter image description here

Friend and Member differ, in that, Friends are like read-only and Members [depending on level] have full access to amend things.

To complicate things further, Locations have their own set of "further" refinable rules e.g. An Organization owns two Locations, but depending on Location rules, a Member [Profile] of that Organization may have full access at one Location, but restricted access at the other. [Sorry: you'll most likely have to open the image in another window for better viewing size.]

enter image description here

So as you can see, the concept of Profiles and Organizations are much the same, as well as this yet to be modelled concept of Friends and Members [...which I imagine will be handled much like the current intermediary tables with setting Owner / Admin / Member / Friend etc. in the record]. Hence, why I’m thinking of the following concept:

See Option.2 in the above image: which would remove the current Organization and Organization_Locations Tables and their relationships, replacing it with the Option.2 Organization Table as a somewhat recursive relationship with Profile.

I suppose the crux of the matter is whether or not I'm being too programmatically minded with Polymorphism to the detriment of simplicity and flexibility, confusing myself entirely in the process ;)

Thanks for your thoughts in advance, much appreciated - M :).

Revised Diagram: https://i.imagestash.io/kDoqKQyOme.jpg

In response to MDCCL's questions:

  1. Yes, Profile is made up of one Person and has the same meaning - though where your rationale is headed - I believe you're correct: Organization and Person could be subtypes of Profile; therefore, a Profile is either made up of one Person, or one Organization.
  2. One Email Address per Profile.
  3. Yes. As above, Organization's should at least have an Email Address.
  4. Correct, one fixed address.
  5. It's a possibility, but a rarity - though from what I'm learning - one should therefore model such for future longevity etc., and just to confirm, a Location could therefore be owned by more than one Person.
  6. Location is definitely the integral entity between most others. Perhaps I will clarify what can be done succinctly here, then let you read though my other answers which will hopefully pertain beneficial additions to this question first [then see my answer to #6 at the end] ;) Re: The Role Owner. An **Organization** can be an Owner of zero or more **Locations**. A Person can be an owner of zero of more Locations [therefore, as you previously surmised; simply put, a Profile can be an owner of zero or more Location/s.

  7. Yes, a Profile that is an Owner of a Location assumes all Role Permissions [super user]; a Profile that is an Admin can amend certain details of the Location, but mainly helps/edits the details/data supplied via all other Profile/s - this will primarily be supplied by 'Basic Member/s' of said Location/s; which leaves Basic Member, who can read-only all related Location details and supply data that must be scrutineered by an Admin/Owner. Beyond this, any Profile [Organization/Person] is much like a Basic Member 'read-only' - let's term them a Guest - but only if the Location is set as Public [and not Private], though they can't supply input like a Basic Member can.

  8. Correct.
  9. Your intuition is amazing! Yes, it is foreseen that a single Location could contain one to many LocationTypes - to complicate things further - it is anticipated that those individual LocationTypes could have varying permissions for Profiles associated with the 'Parent' Location; of which, permissions would filter down from the Location to the LocationType/s [much like OS folder security permissions]. I note via your diagram you might be referring to type more as a description?
  10. Yes.
  11. See 12.
  12. Correct, the ability for Profile1 [Person or Organization] to act upon Profile2 [Person or Organization] owned Locations [if they're Friend/Member with correct permissions] is paramount.
  13. Very reasonable - a) agree. b) agree. c) Yes, hmm?...Perhaps it should be much the same as Profile[person] to Profile[person] = Friends. Whatever the description, it would revolve around Location, as Organization/s will act upon other Organization Location/s; though semantically, I doubt any Organization would want to appear subservient as a 'Member' of that Location's Organization to be able to so, 'no matter how good the cause.'

[6]. This is still a tad grey for me, but here goes...To possibly my detriment, the similarity between Member/Friend relations are so close that I thought to combine them; in hindsight with your diagram and interpreting, it appears you may be right to keep them separate [I was going to differentiate the single relationship via enum property: Owner/Admin/Member/Friend]. Your concept as e.g.: A Location that is Owned by an Organization will have zero to many Profile [Person or Organization] act upon it, though there should be a clear difference between how the Profiles act upon the location via its relation [Member or Friend] denoted through Roles. So perhaps, the default relation between any Profile is Friend [much like Guest at Answer#7], enabling them to view the read-only Location data and msg/email the Location Owner/Admin - but not allow them to receive Location updates, news, etc., as a Member would.

2
  • What software did you use to create your ERD examples?
    – Elias
    Commented Dec 12, 2016 at 15:01
  • Microsoft Visio ;)
    – MVC Newbie
    Commented Dec 16, 2016 at 5:13

2 Answers 2

14
+500

It is great that you are taking the time to understand, classify and model the data you are dealing with since, from my personal experiencie, all this makes the whole development process easier and very flexible for future changes. And I am quite sure that you are also aware of this already.

Preliminary data model and assumed business rules

I defined a list of business rules that I have assumed after reading your question and examining closely your diagrams, in order to describe my understanging of your specifications. After defining such list, I derived an IDEF1X[1] data model that I decided to upload as a .PDF document in an external platform (Dropbox), since due to its format this data model does not fit well in an embedded image. These two instruments are going to be useful as references for some important points that I enumerate below in the section entitled Aspects to resolve in order to keep moving forward.

First, here is the…

Since it is only that, preliminary, consider it as an means helping us to acomplish the desired final data model.

Assumed business rules

Said preliminary data model was derived from a collection of business rules (inferred from your question) that I will enumerate as follows:

Organizations and profiles

Note that Profile is currently understood as a synonym for Person.

  • An Organization is a friend of one-to-many Profiles.
  • An Organization is a friend of one-to-many Organizations.
  • An Organization is a member of one-to-many Organizations.
  • A Profile is a member of one-to-manyOrganizations.
  • A Profile is a friend of one-to-many Profiles.
  • A Profile is a member of one-to-many Profiles.

Locations and addresses

  • An Organization owns one-to-many Locations.

  • A Location is classified by one-to-many LocationTypes (only one at a given point in time).

  • A Location may have one-to-many Addresses (one Physical, one for Shipping, one for Billing, or one that serves all said purposes, or one that combines two purposes and another that serves only one of them).

  • An Address may be kept by one-to-many Profiles or, put another way, a Profile keeps one-to-many Addresses.

  • A specific Address may be used by one-to-many Profiles (serving as Physical for one Profile, being used for Billing by a different one, etc.). So, an Address works in a similar way for Locations and Profiles.

    • Thus, an individual Address may be, at the same time, of type Physical, Shipping and Billing.

Locations and roles

  • A Location opens one-to-many Roles.
  • A Role may be carried out in one-to-many Locations.
  • A Profile (once it has been set as Member of an Organization) may carry out one-to-many Roles, in one-to-many Locations (but only one specific Role in each Location at a particular point in time, i.e., never two or more Roles at the same time).

Aspects to resolve in order to keep moving forward

In order to keep advancing in the resolution of your data model, here is a list of relevant points that, once we work them out, are going to help us to reach this goal:

  1. I have assumed that the term Profile in your context has a similar (or the same) meaning as that of Person, but it could be a bit different. In this way, would you say that, in your scenario, the entities Organization and Person are subtypes of Profile?

  2. Can a Profile (or Person) own one-to-many EmailAddresses, or is a Profile (or Person) fixed to exactly one EmailAddress?

  3. Would you like to provide the possibility for an Organization to be contacted via Telephone and Email, or you want to restrict that to be possible only for a Profile (or Person)?

  4. I assume that a Location is fixed to exactly one Address of the type Physical, is this correct?

  5. Is it possible for a Location to be shared by one-to-many different Organizations or, otherwise, a Location can be owned by only one Organization?

  6. You have stated via comments that the fact of being a Member and a Friend is the same. As you can see in my proposed preliminary data model, I followed you original specifications and depicted all the possible combinations of membership and friendship between Organization and Profile (or Person) in different entities since I think that it can be helpful in the effort of defining the best possible structure for that part of your scenario. In this sense:

    • I assume that the the statement an Organization is a Member of another Organization has different effects than the statement a Profile (or Person) is a Member of an Organization regards the entity called Location.
    • As you can see in the data model, I think that the Role of Owner is only valid for an Organization and, to me, the valid Roles for a Profile (or Person), inside a Location are Admin and Member. What do you think about all this? Since you are in direct contact with the business rules that apply to your situation, you need to tell me if my assumptions are correct.
  7. Can a Profile (or Person) play different Roles inside the same Location? i.e., can a Person be, at the same time, the Admin and also a Member of the same Location? What are the rules in this regard?

  8. I think that the same Profile (or Person) can play different Roles in different Locations. For instance: A specific Profile (or Person) is the “Admin” in Location “1”, and this same Profile (or Person) is a “Member” in Location “2”, at the same time. Am I right?

  9. Is it possible for a particular Location to have different LocationTypes at the same time, or is an individual Location fixed to hold exactly one LocationType?

  10. Does the attribute Organization.Website represent the website address of a particular organization, such as “dba.stackexchange.com”?

  11. If Profile “1” (understood as Person) is a Member (or Friend) of Profile “2”, is it possible for Profile “1” to carry out a Role in a Location owned by Profile “2”? I consider that such scenarios are only valid for the relationships between an Organization and a Member Person so, what do you think?

  12. In a similar way, if Organization “1” is a Member (or Friend) of Organization “2”, is it possible for Organization “1” to carry out a Role in a Location owned by Organization “2”? Again, I think that this kind of scenarios are only valid for the relationships between an Organization and a Member Person, is this correct?

  13. In this regard —while I am writing this questions— I think that it would be reasonable to say that there are only three different kinds relationships involving Organizations and Persons, and we can define:

    • (a) The relationship between an Organization and a Person as “Membership”.
    • (b) The relationship between a Person and another different Person as “Friendhip”.
    • (c) We have yet to find a meaningful name in order to describe the relationship between an individual Organization and another different Organization.
    • So, let me know what you think about (a), (b) and (c).
  14. Is it possible for an Organization to be a Friend (or a Member) of one-to-many different Organizations at the same time? Or it is only possible for an Organization to have only a relationship with exclusively one different Organization?

Successive data model depicting the first advance

In attention to your responses and resolutions to the pending aspects that I have listed above, I have created the following…

Although I do not feel quite comfortable with it yet, this new data model expresses the following business rules:

  • A Profile is either an Organization or a Person.[2]
  • A Profile may be the offering friend of one-to-many FriendProfiles, and a Profile may be the accepting friend of one-to-many FriendProfiles.[3]
  • A Location may consist of one-to-many Locations.[4]

Answers to your subsequent specific comments

It's really interesting for me to note/compound the separation of concerns [e.g. LocationAddress and ProfileAddress] - for I obviously wanted to rush in and hold them all without the correct relations [funnily, It didn't feel right with my original ERD].

Yes, that is a good comparison, although I would not call it separation of concerns (which is, certainly, a fundamental principle in application programming and design), since this term commonly pertains to the application development stage and we currently find ourselves in the stage of understanding the data and designing its logical structure.

From my personal experience, I consider that this phase has to do with putting the significant things into their whole context, it has to do with seeing the associations that exist between the different entities that are of relevance in the particular scenario of interest, and then depicting these things in a data model. In the specific case on which you are commenting about, the Address entity may have different kinds of connections with other entities, one with Profile and a different one with Location.

And, yes, when something does not feel right or natural, it may well be a sign that one needs to put more effort in order to understand the pertinent data. In this manner, the Address entity is one of the things that I consider that needs more attention, since I think that the relationship between a Profile and an Address could be handled by means of the Location entity (due to the fact that every Location must have at least one physical Address), therefore we could dismiss the ProfileAddress associative entity depicted in the latest model, but you should continue analizing these points and let me know your ideas.

Also, is it common practice in IDEF1X to change PK/FK denotions in entities for better readability [e.g ProfileId - LocationOwnerProfileId]?

Yes, that is a very clever remark from you, since IDEF1X recommends the use of role names for denominating FOREIGN KEYS, in order to capture the meaning of such attributes in accordance to the entity in which it is being used. It is also worth noting that this is also strongly related to the concept of primary keys migration. As a matter of fact, the use of role names precedes IDEF1X, since it was originally presented by Dr. E. F. Codd in his 1970 seminal text. In this manner, one can clearly see the fidelity that the IDEF1X standard keeps towards the relational model.

I'd be intrigued to learn what you don't particularly like/feel it doesn't model, with/in the solution?

Besides the details already described above about the Address entity, I am not sure if the Roles carried out by a given Profile in a particular Location are equivalent for an Organization or an Person. From my perspective, a Person first needs to be associated with an Organization, and then this Organization would appoint said Person to perform a Role in a particular Location, but you know the scenario better, so this rules may be needless. In this regard, I am going to insist about the fact that it would be very helpful for me to know the contextual description or meaning that the future users of this data structure give to Organization, Profile, and Location, but I understand that this may be considered confidential information, so this would be a limitation.

With the current structure, it seems like everyone (Organization or Person) can be related to anyone (again, Organization or Person) and can be/do anything (Role) anywhere (Location) but, perharps, this is preciselly what you and the users are expecting from this database, for which you will provide well defined constraints, of course. If this is the case, then we are almost providing a final solution. Since, naturally, your opinion is decisive in this situation, you should also analize this ideas and then let me know your conclusions so that we can take the final steps.

Feasible second advance

Unfortunately, the comunication stopped a few weeks ago, I guess because of work commitments that you must meet, which is completely reasonable. I would have been much more content if we had developed a more stable and robust model but, due to our previous interactions, I can assume that I have been able to point you in the right direction.

In addition to what has already been presented in this question and answer process, I consider that providing a new progression from the previous data models may be helpful for other seekers with a similar problem. So, I have created the…

Organizations and Profiles Preliminary Data Model — Second Advance

As can be seen in such data model, I have removed the many-to-many relationship that I have depicted in the preceding models between Profile and Address, since a given Profile is already related to one-to-many Addresses via its owned Locations.

Another change that is illustrated in this new advance is the fact that it now includes the possibility that a given Location can be owned by one-to-many Profiles. Consequently, I have changed the Location PRIMARY KEY (by dismissing the LocationOwnerProfileId attribute) and then added an associative entity (many-to-many) that relates Profile with Location.

Notes

1. IDEF1X is a highly recommendable data modeling technique that was defined as a standard in december 1993 by the U.S. National Institute of Standards and Technology (NIST).

2. This is an ocurrence of a (super)type-subtype cluster. In case you are interested, here is an answer in which I deal in a more detailed manner with this kind of relationships.

3. An example of a many-to-many hierarchical relationship, and is very simliar to the structure that gave definitive solution to the “Parts Explotion Problem”. Such solution was, of course, introduced by Dr. Edgar Frank Codd in his 1970 enormously influential paper “A Relational Model of Data for Large Shared Data Banks”.

4. As such, this is an instance of a one-to-many (or many-to-one) hierarchical relationship.

1
  • 7
    Please note my revised question that contains answers to your questions. I know personal correspondence is frowned upon by dba - but I hope they can indulge me when I say - "your response is the most proficient and helpful addition I've ever received to any question, ever" - so a huge heartfelt thanks for all your effort thus far, I'm truly humbled and appreciative! [...and if this doesn’t help many other members now and into the future, I'll eat my keyboard ;)]
    – MVC Newbie
    Commented Jun 30, 2015 at 3:39
4

I think you are trying to blend together concepts from object modeling and concepts from data modeling in a way that isn't helping you to clarify your own understanding of the problem. I hope I can clear the clutter a little without too much rambling.

The relational model, as such, does not support inheritance, never mind polymorphism. This means that a rather specialized design pattern has to be used when modelling a real life situation that is easily handled by inheritance and polymorphism in an object model. More on that special design pattern later.

When the ER model was first developed, it was supposed to be an implementation agnostic alternative to relational modeling. At first, it didn't have anything like inheritance either. But some time in the 1980s or 1990s, the model was extended to provide some of the same expressive capabilities that you get with inheritance. This was known as the "extended ER model", but for all practical purposes, the ER model of today includes EER features.

One EER feature goes by the name "generalization/specialization". You can search for and read up on this concept on the web. Gen-spec provides much the same expressive capability that classes and subclasses provide in an object model. However, Gen-spec does not deal with the issues surrounding relational table design for a gen-spec situation. More on that later.

In ER modeling, a relationship always involves the same entities. Therefore, the friend relationship between an organization and a profile is not the same thing as the friend relationship between a profile and another profile. The two relationships need different names. You'll just tie yourself up in knots if you don't follow this rule.

Either that, or you need to come up with a generalized entity of which Organizations, Profiles, and possibly Locations are all specializations. I don't understand your case well enough to help you with that.

Moving on, I notice that you are combining your relational model and your ER model together into a single model. Most seasoned database architects do this. But I advise you to keep the two models separate (although reconciled with each other) until you have gained proficiency.

Finally, how does one design relational tables that represent a gen-spec situation? Try looking up these two design patterns "Class-table-inheritance" and "Single-Table-Inheritance". There are two tags for these in over in Stackoverflow. There are also some pretty good presentations of the patterns on the web. I particularly like Martin Fowler's treatment. He seems to know how object modelers think. Hope this helps.

2
  • Thanks for your time and great reply - Ok, so those concepts seem to lean towards my option: 2. Please see revised: diagram in question. The core entities being Profile and Location - Organization is really just a Profile with some extended attributes. I have also decided that Friend/Member are the same as well. *Many Profiles/Organizations can have many Profiles/Organizations as Members. *Many Locations can have many Profiles/Organizations associated with them - the type of assoc. will most likely be handled by enum: Owner / Admin / Member. Would that be comparable with my revised diagram?
    – MVC Newbie
    Commented Jun 28, 2015 at 10:43
  • AFAICT, the table Profile_Members represents a recursive many-to-many relationship between one Profile and Another. That's as far as I've gotten. Commented Jun 29, 2015 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.