I'm really confused on the difference between disjoint and overlapping design constraints in relational databases. I've looked around, but have had a hard time finding an understandable example. Could someone please explain this to me via an example?
Thanks!
Say you have a super class 'musician' then two sub classes 'singer' and 'guitar player'.
In a disjoint constraint you would have to put the musician in either one or the other sub classes. In an overlapping constraint the musician can be put in both.
Let's say you have a super class 'account' with sub classes 'Savings Account' and 'Current Account'. This is a disjoint constraint situation because a bank account can either be Savings or Current. It cant be both at the same time.
For an overlapping constraint situation, let's say we have a super class 'Person' and subclasses 'Customer' and 'Employee'. In this case, a person can be Customer and Employee both. Therefore, overlapping.
The disjoint rule states an entity instance of a supertype can only be a member of one subtype. The overlap rule states an entity instance of a supertype can be a member of multiple subtypes.
Example of disjoint rule:
Instance of Super-type Animal can only be member of exactly one of these Sub-types being Panda, Cheetah and Dog
Disjoint Union , (An animal can either be Panda or be Dog or be Cheetah but can't be any two or more at the same time)
Example of overlap rule: Instance of Super-type Person can be member of multiple Sub-types being Woman, Driver and Engineer
Overlapping Union , (A person can be a Woman and that same Woman can be Driver and that same Woman can be Engineer at the same time)
Let's simplify this confusing concept. First of all, understand that there is a discriminator between subtype and supertype. If the value of a discriminator is not null and appears in supertype entity instance then that must be linked with the only one subtype. This is called disjoint constraint.
For example, you say in school a person can be teacher and student but a teacher can't be a student and vice versa. Then in person supertype and (student, teacher) subtype exists a discriminator called person_type. If person_type in person entity is 't' then it is linked with teacher subtype only not with a student. Similarly, we can write it for the student.
Now, in overlapping constraint, the supertype entity instance can appear in many subtype instance.
In overlapping example consider a teacher can be a student also. Then 't' can be linked with student and teacher subtype entity.
suppose Member is super class and its two sub-classes one is student and 2nd one is faculty,if(Member) of subclass(student or faculty)not both then it is disjoint.
if member both of its subclass then it non-disjoint or overlapping.
.
Related
I have two ERD examples involving subtypes. I cannot seem to find any definitive information online or in textbooks on connecting other entities to subtypes and how far you can inherit keys from subtypes, if at all. Those with good eyes may notice that I recently asked a similar question regarding subtypes, but it was for a different scenario and so far I only received a referral to another question that only explains the basics of subtypes which I do not need - I feel this is a more advanced topic to solve.
My specific issue is I need to know whether the Bridging entity called ENROLMENT is allowed to inherit the PK/FK from STUDENT entity, a Subtype of PATRON. If so, is PatronNumber and/or StudentNumber attributes allowed.
The two ERD examples are slightly different. Version 1 uses PatronNumber from the Subtype Student. Version 2 includes another PK called StudentNumber. Is this ok to add as a PK and can ENROLMENT reference from this? Which is better, if any?
Cheers!
The first version is to be preferred, for the reason that with a single value, PatronNumber, you can obtain all the information about the student with a single join, while in the second case you need to perform two joins.
Imagine, for instance, that you need to know the name of all the students that are enrolled to the course number 3: you can simply perform a join between Enrollment and Patron, while in the second case you need a join between Enrollment and Student and then between Student and Patron.
If your application requires explicitly a StudentNumber different from PatronNumber, you can simply add the attribute to the Student, and declare it unique.
I am trying understand cases where vacuous entailment occurs due to use of universal quantification in Protege. That is, axioms of the form:
A rel *only* B
Here is my setup:
I have created an ontology that (more or less) follows the one described in this Ontogenesis article:
http://ontogenesis.knowledgeblog.org/1260
It consists of an owns relation and two high level disjoint classes: person and pet.
Under the pet class, I have three primitive disjoint classes: dog, elephant, and newt.
Below the person class, I have a defined class pet owner, defined as follows:
'pet owner' equivalent_to person and (owns only pet)
Lastly, I have created and individual person, named person 1, that does not own any pets.
Universal quantification:
My understanding of universal quantification is that the only quantifier describes those individuals that only have relationships to individuals of a specific class. This entails that individuals that do not have any relationships to another individual would also be described by universal quantification.
In my example, I thought person 1 would be inferred to be a pet owner, since person 1 does not own any pets or stand in any other relationships. However, when I run the reasoner (HermiT and Pellet), this does not turn out to be the case. Person 1 is not inferred to be a member of pet owner.
So, it seems that I am not understanding universal quantification. Can someone please help me?
The problem here is that you didn't take into account Open World Assumption (OWA). By OWA the ontology only contains facts that are known; there might be other facts. If you say nothing about the things person 1 owns, it doesn't mean that it owns nothing. It might own other things, that are not in the ontology. So your universal restriction may prevent someone to be a pet owner (in case they own something that is not a pet, and the corresponding axiom is in the ontology). To make someone a pet owner, you might 'close' the information about it, e.g. saying that known pets are the only things that person owns. For this you may use owns only {pet1, pet2, pet3} construction.
My assignment is to draw an ER model (by hand) using Chen notation using the specifications below:
http://i57.tinypic.com/73ff2f.png
If you have questions about these specs. I'll play the role of the
client who will resolve them.
The database will serve a university.
Students have id's, names and gpa's. They must have exactly one major,
but they could have minors as well. Each major or minor is a
department which has a unique name and a phone number. For each
student with a minor, we record the date she signed up for it. Faculty
members are associated with a unique department and have id's, names
and office locations. Each internship is held by a particular student
at a particular compain and is supervised by a particular faculty
member. We also keep track of the last term in which that student
registered under that advisor for an internship at that company.
Students may have many internships over time. A given faculty member
may supervise many students at a given company, and she may supervise
a given student at several companies. However, for a given student and
company, there can be only one faculty advisor.
Students, Departments,
Faculty and Companies should be your entity types. Internship should
be a ternary relationship type. The specs should also lead you to some
binary relationship types. Don't add any ingredients to this mix other
than what appear in the specs.
Below is my work:
http://i60.tinypic.com/28rf7tf.jpg
Can anyone please help as I really need a better understanding of this (my professor is AWFUL at explaining this).
You missed (per your assignment's last paragraph) a department entity type. (Box.)
You missed 'Faculty members are associated with a unique department'. That's a relationship between those two entity types. (Diamond with lines to those boxes.)
You could have those major and minor entitie types that are 1:1 with departments. (Your present boxes with each a line to its own diamond each with a line to department.) But (per your assignment's last paragraph not listing them as entities) you could have major being a relationship 'student[s] has a major in department [d]' and similarly for minor. (Lines from student to each of two diamonds each with a line to department.) But the assignment actually says 'each major or minor is a department' so that's major as 'student[s] has major department [d]' and similarly for minor. (Same picture.)
Per your assignment's last paragraph you should make internship a ternary relationship. (Under Chen it's a relationship diamond (possibly with its own properties) formed by 3 lines to entity type rectangles (possibly with their own properties) rather than an entity box.) However, it's not clear exactly when your assignment considers that an internship holds. (It tells us what relationships hold; it's just not clear which one it wants to call interning.) (Although we can look for interpretations consistent with it being ternary.) One is 'student [s] interns at company [c] supervised by faculty member [f]'. But since 'for a given student and company, there can be only one faculty advisor' that notion of internship is more simply characterized by a binary relationship 'student [s] interns at company [c]'. But then you still need a relationship 'faculty member [f] advises student [s] at a company [c]'. So I will suggest that your assignment expects the former. We can add property term. (This is more reasonably called a relationship on student, company, faculty member and date; but E-RM considers relationships to be on entities. Although it all depends on your class's method's particulars.)
(The possibility of multiple reasonable variations is why you should propose a particular design fully handling a particular specification in a SO question.)
A problem with the E-R Model [sic] is that it introduces needless distinctions between entities, reltionships and properties. There is really no distinction between a relationship instance and an entity. Eg: Here we could just as well have an internship be per above an entity in a 4-way relationship plus property. Eg: Your assignment says 'each major or minor is a department'. But a major or minor isn't a department. A major or minor could be considered a subject, which would be the subject after which a department is named or the subject of the degree offered by a department. Or we could just have relationships in which a department participates but the relationship is about that department's subject or name or degree being a major or minor.
(If an internship as relationship participated in its own relationships I don't know how your instructor's particular method would keep the further lines organized. Some methods add internship entities (box) 1:1 with relationships (diamond); then some methods specially associate the entity type with the relationship as a reification while some make the relationship 4-way by including the reified entity type. Eg 'internship [i] is student [s] at company [c] and ...'.)
(Correctly speaking there are entity types vs relationships and entities vs relationship instances. But the assignment talks of relationship "types".)
Re E-RM see this answer and this one. Also the E-RM wiki page section 'Entity–relationship modeling'. (Which correctly mentions misinterpretations of Chen's E-RM & E-RDs by some related modeling and diagramming methods and tools and even some presentations of E-RM itself. But the 'Overview' is nonsense.)
Re E-RM problems see this.
Both are looking same to me. i am not getting the exact deference. i search on different forums and sites but not getting clear. what is the difference between them?
The exact difference is as follows. You have to first separate the total/partial participation constraints to understand this better and we'll take them into account later on.
Disjoint Constraint
Any instance can map to at most one subclass. Not more than that. e.g Bank Account can be either 'Savings Account' or 'Current Account' not both. So when the database is operational, every given instance will be mapped to exactly one subclass defined under the super class. Another example would a meal will be mapped to either Veg or Non-veg..It can't be both.
Partial Constraint
Any instance may or may not map to multiple sub classes of a given super class. This usually happens when an instance play multiple roles and not limited to a single one. e.g Employee may map to either supervisor, manager or both. This means an employee can play both the roles of a manager and a supervisor. Another example would be a musician who maybe mapping to either violin player, guitar player, flutist,saxophonist or all of them.
Note:
So when you specify an 'ISA' relationship your subclasses may behave in either disjoint way or overlap way.. They can't be both, meaning that Disjoint is the exact opposite of Overlap constraint.
Now let's focus on Total and Partial constraints.
Regardless of the overlapping/disjoint constraints, total/partial mean 'do all the instances support the specialization?' question. So when the database is operational and if your ISA relationship is total, any instance coming will be directed to one of the sub classes and nothing will stay in the super class. Conversely, if it's partial, some instances may not have an appropriate subclass so they will stay in the super class.
This brings up the interesting notions as follows.
Total-Disjoint- All the instances coming, will map to one subclass only and will not be shared among other subclasses
Partial-Disjoint- All instances coming, may stay with superclass or map to one of the sub classes only
Total-Overlap- All instances coming, will map to multiple subclasses.
Partial-Overlap- All instances coming, may stay with the super class or map to multiple sub classes.
Total Participation vs Partial Participation.
In total participation, patient must be an outpatient or resident patient, it can not simply be the superclass patient type. Partial participation allows you to have a patient be just a patient.
Under Total specialization, there can be no entities that are of a superclass but are not of any of the subclasses. This is represented by the double line drawn from patient
Disjoint means a subclass type patient can be either an outpatient or resident patient but not both. Subclasses can only be one subclass from the superclass not both.
So in both diagrams a patient must be a one of the subclasses, but the disjoint means it can not be both subclasses.
When you use a total specialization, in the example shown, a patient must be either a outpatient or a resident patient, which means that all patients needs to be one of the sub types(outpatient or resident).
The disjoint rule is different in the way that a patient needs to be in only one subtype.
Basically, as I understand, the difference is that the total specialization says a super type needs to be in a sub type and the disjoint says it need to be in only one sub type.
I hope this helps.
There is a link that you can read about all these types and rules:
http://www.tomjewett.com/dbdesign/dbdesign.php?page=subclass.php
There are 2 different decisions {Total participation vs Partial participation} and {Disjoint vs Overlap}.
Participation -> ∈ {subclass1,..,subclassN} vs ∈ {subclass1,..,subclassN, superclass}
Subclass Type -> ∈ {S1 xor S2 xor ... xor SN} vs ∈ {S1 or S2 or ... or SN}
where S is the entities.
I was simply wondering, how an ISA relationship in an ER diagram would translate into tables in a database.
Would there be 3 tables? One for person, one for student, and one for Teacher?
Or would there be 2 tables? One for student, and one for teacher, with each entity having the attributes of person + their own?
Or would there be one table with all 4 attributes and some of the squares in the table being null depending on whether it was a student or teacher in the row?
NOTE: I forgot to add this, but there is full coverage for the ISA relationship, so a person must be either a studen or a teacher.
Assuming the relationship is mandatory (as you said, a person has to be a student or a teacher) and disjoint (a person is either a student or a teacher, but not both), the best solution is with 2 tables, one for students and one for teachers.
If the participation is instead optional (which is not your case, but let's put it for completeness), then the 3 tables option is the way to go, with a Person(PersonID, Name) table and then the two other tables which will reference the Person table, e.g.
Student(PersonID, GPA), with PersonID being PK and FK referencing Person(PersonID).
The 1 table option is probably not the best way here, and it will produce several records with null values (if a person is a student, the teacher-only attributes will be null and vice-versa).
If the disjointness is different, then it's a different story.
there are 4 options you can use to map this into an ER,
option 1
Person(SIN,Name)
Student(SIN,GPA)
Teacher(SIN,Salary)
option 2 Since this is a covering relationship, option 2 is not a good match.
Student(SIN,Name,GPA)
Teacher(SIN,Name,Salary)
option 3
Person(SIN,Name,GPA,Salary,Person_Type)
person type can be student/teacher
option 4
Person(SIN,Name,GPA,Salary,Student,Teacher) Student and Teacher are bool type fields, it can be yes or no,a good option for overlapping
Since the sub classes don't have much attributes, option 3 and option 4 are better to map this into an ER
This answer could have been a comment but I am putting it up here for the visibility.
I would like to address a few things that the chosen answer failed to address - and maybe elaborate a little on the consequences of the "two table" design.
The design of your database depends on the scope of your application and the type of relations and queries you want to perform. For example, if you have two types of users (student and teacher) and you have a lot of general relations that all users can part take, regardless of their type, then the two table design may end up with a lot of "duplicated" relations (like users can subscribe to different newsletters, instead of having one M2M relationship table between "users" and newsletters, you'll need two separate tables to represent that relation). This issue worsens if you have three different types of users instead of two, or if you have an extra layer of IsA in your hierarchy (part-time vs full-time students).
Another issue to consider - the types of constraints you want to implement. If your users have emails and you want to maintain a user-wide unique constraint on emails, then the implementation is trickier for a two-table design - you'll need to add an extra table for every unique constraint.
Another issue to consider is just duplications, generally. If you want to add a new common field to users, you'll need to do it multiple times. If you have unique constraints on that common field, you'll need a new table for that unique constraint too.
All of this is not to say that the two table design isn't the right solution. Depending on the type of relations, queries and features you are building, you may want to pick one design over the other, like is the case for most design decisions.
It depends entirely on the nature of the relationships.
IF the relationship between a Person and a Student is 1 to N (one to many), then the correct way would be to create a foreign key relationship, where the Student has a foreign key back to the Person's ID Primary Key Column. Same thing for the Person to Teacher relationship.
However, if the relationship is M to N (many to many), then you would want to create a separate table containing those relationships.
Assuming your ERD uses 1 to N relationships, your table structure ought to look something like this:
CREATE TABLE Person
(
sin bigint,
name text,
PRIMARY KEY (sin)
);
CREATE TABLE Student
(
GPA float,
fk_sin bigint,
FOREIGN KEY (fk_sin) REFERENCES Person(sin)
);
and follow the same example for the Teacher table. This approach will get you to 3rd Normal Form most of the time.