patternsqlModerate
Conceptual ERD Multi-table many to many, or possibly recursive?
Viewed 0 times
multipossiblyconceptualrecursivemanyerdtable
Problem
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:
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.]
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 Diagra
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.
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.]
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 Diagra
Solution
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
Locations and addresses
-
An
-
A
-
A
-
An
-
A specific
Locations and roles
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:
-
I have assumed that the term
-
Can a
-
Would you like to provide the possibility for an
-
I assume that a
-
Is it possible for a
-
You have stated via comments that the fact of being a
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…
- Organizations and Profiles Preliminary Data Model.
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
Organizationis a friend of one-to-manyProfiles.
- An
Organizationis a friend of one-to-manyOrganizations.
- An
Organizationis a member of one-to-manyOrganizations.
- A
Profileis a member of one-to-manyOrganizations.
- A
Profileis a friend of one-to-manyProfiles.
- A
Profileis a member of one-to-manyProfiles.
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
Addressmay be, at the same time, of typePhysical,ShippingandBilling.
Locations and roles
- A
Locationopens one-to-manyRoles.
- A
Rolemay be carried out in one-to-manyLocations.
- A
Profile(once it has been set asMemberof anOrganization) may carry out one-to-manyRoles, in one-to-manyLocations(but only one specificRolein eachLocationat a particular point in time, i.e., never two or moreRolesat 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:
-
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?-
Can a
Profile (or Person) own one-to-many EmailAddresses, or is a Profile (or Person) fixed to exactly one EmailAddress?-
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)?-
I assume that a
Location is fixed to exactly one Address of the type Physical, is this correct?-
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?-
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 Organizationhas different effects than the statementa Profile (or Person) is a Member of an Organizationregards the entity calledLocation.
- As you can see in the data model, I think that the
RoleofOwneris only valid for anOrganizationand, to me, the validRolesfor aProfile(orPerson), inside aLocationareAdminandMember. What do you think about all th
Context
StackExchange Database Administrators Q#105195, answer score: 14
Revisions (0)
No revisions yet.