star on the left hand
side indicating that C2 objects
can be related to any number
of "C1" objects and, as
a reminder, star is an abbreviation
for "zero, dot, dot, star."
Many to many has no
restrictions on the relationships.
So that would be a star on both sides.
Pretty simple and the last
concept is the idea of complete relationships.
So a complete relationship is complementary to these others.
It says that every object
must participate in the relationship.
So we can have a complete one
to one, and that would
be one dot dot one on both sides.
We could have a complete many to
one, and that would
be on the left side
one dot dot star, and
on the right side one dot dot
one and, finally, a complete
many to many would be
one dot dot star on each side.
As a reminder, the default if
we don't specify the multiplicity
is a one dot dot one both sides.
So that would be a complete
one to one relationship.
Ok, we've finished with classes and with associations.
Now let's talk about association classes.
Association classes generalize the
notion of associations by allowing
us to put attributes on the
association itself and, again, we'll use our example.
So we already knew how to
specify that students apply to
colleges, but what if associated
with the application we wanted
to have, for example, the date
that they applied and maybe the decision of that application.
We don't really have a way
to do that without adding a
new construct, and that construct
is what's known as an association class.
So we can make a class and we'll just call it "App Info".
And it looks like a class,
it's got the box with the name at the top and the attributes.
And then we just attach that
box to the association,
and that tells us
that each instance of
the association between a student
and a college has additional information,
a date of that application and the decision of that application.
Now there's a couple of things I want to mention.
First of all, in a number
of examples, I'll probably leave
out the multiplicities on the ends of the associations.
That doesn't mean I'm assuming the default one one.
It's just when it's not relevant, I'm not going to focus on that aspect.
Now when we have students associated with colleges.
So we have a student here we have a college.
Then we have an association between those.
Now what we're saying is that
association is going to
have affiliated with it a date and a decision.
What we cannot describe in
UML is the possibility
of having more than one
relationship or association between the
same student and the same college.
So when we have an association
that assumes at most one
relationship between two objects.
So, for example, if we
wanted to add the possibility
that students could apply to
the same college multiple times so
maybe you know that want
to apply for separate majors.
That would actually have to be captured quite differently.
We'd have to add a separate
class that would for the
application information with separate
relationships to the students and colleges.
So this is a, in my
mind, a slight deficiency of UML.
Again, that and it only
captures, at most, one relationship
between the two specific
objects across the two classes.
Now, sometimes we can make
a design that has an association
class and it turns out
we didn't really need it and
we're going to come back to
multiplicities to see how this
can happen, so again let's
take a look at just generic classes C1 and C2.
Let's say that we have an
association between them and then we have an association class.
We'll just call it AC.
And that's gonna have some
attributes, we can call them A1 and A2 for now.
And of course, there's attributes
in C1 and C2 as well.
Let's suppose that the multiplicity
on, let's say the left
side is star so anything
goes, and on the right
side we have one to one.
So what that multiplicity says is
that each object Of C1
is related to at most one object of C2.
So, actually exactly one object in this case.
So we know that there's
going to be just one association for
each object of C1, and
if there's only going to
be one association actually we
could take these attributes and we
could put those attributes as part
of C1 instead of having
a separate association class, so
for example If this class
happened to be the student class,
and this was the college class,
and we insisted that each
student apply to exactly one
college then the attributes
we had down here, the date
and decision, could be moved
into the student class, because we
know they're only applying to one
college, so that would be
the date and the decision for
the one college they're applying to.
Furthermore, if we had zero
dot dot one, we can
still move these attributes here
and, in that case, if a
student was not involved in a
college - had not applied
to a college at all or, more
generally, an object of "C1"
was not related to any
object of "C2" then those
attributes would have the equivalent
of null values in them.
By the way, it is possible for
an association to be between a class and itself.
For example, we could have
our student class and maybe
we're going to have an association
called "sibling", a student
being associated with another student
because they're siblings, an association
between a class in itself
is written with a line tgat
just goes between the class and itself.
And then we could label that sibling.
And for multiplicities we can
assume that every student
has between 0 and an
arbitrary number of siblings lets
say, so we can put
a star on both ends of that association.
A more interesting association might
involve colleges where say
we have for every college
a flagship main campus.
But then some colleges have separate
branch or satellite campuses, so
that would be an association
between a college and itself
saying that one college is
a branch of another college.
Now let's think about the multiplicities here.
First of all, when we
have a self association, in UML
we're allowed to label the two ends of the association.
So I could, for example, say
on one end we have the
home campus.
And on another end we have the satellite campus.
And now with those labels
we can see the asymmetry and
that lets us get our associations right.
So let's say that every satellite
campus must have exactly one
home campus, so that would
be a one dot dot here
and every home campus can have
any number of satellite campuses.
Or actually, let's say something else.
Let's say every home campus
can have between zero and ten
satellite campuses be a
zero dot dot ten on that side of the self association.
Ok, we're finished with the first
three let's move on to sub classes.
For sub classes we're gonna do
a fairly large example that involves
students that we're gonna
separate into foreign students and domestic students.
We're also going to separately specify
students who have taken AP
classes and those will be our AP students.
So we're going to have the student
class as the top
of our hierarchy and the
student class will, again, have
the student ID, let's say
the student name, and GPA,
and we'll say the the student
ID is the primary key for
objects in that class, we're
going to have three sub classes,
one is going to be the
foreign students, we'll call it
foreign S, one is going
to be the domestic students and
then we're also going to
have a sub class for AP students.
and I'm going to assume that
you already know a little bit about sub classing from programming.
So the idea is that when
we have a sub class,
there are attributes that are
specific to the objects
that are in that sub class
and they'll inherit the attributes from their super class.
So we're gonna make student be a super class here.
And this is how we draw it,
with three sub classes here
for foreign student, domestic student, and AP student.
And we'll say that foreign students
have in addition to a
student ID, a student name and
GPA, a country that they come from.
We'll say that Domestic students
are going to have a state
that they come from and we'll
also say that they have
a Social Security number, which we
don't know that foreign students would necessarily have.
AP students, interestingly, is going to be empty.
It's not going to have any
additional attributes, but
the AP students are the
students that are going to
be allowed to have a
relationship with AP courses.
We'll say that the
AP course has a course number
and that's probably the primary key.
And maybe a title for the course and some units for the course.
And then when one of our AP students takes the course.
We'll call this "Association took".
We're going to have an association class
that goes along with that, that's
going to have the information,
let's called it "AP info", about
them taking that particular AP
class and we'll say that
association class has for
example the year that they
took the class and maybe the grade that they got in the class.
And lastly let's add some multiplicities.
Let's say that AP students
can take between one and
ten AP classes but they
taken at least one to
be an AP student and let's
say that every course has taken
by at least one student and
arbitrary number of students.
So this is one of the
biggest UML diagrams we've seen so far.
Again, this is a superclass up here.
And we have our subclasses down here.
And then we also have an
association, and an association class, and some multiplicities.
And again notice that
is ok that there are
no attributes in the AP
student sub class that sub
classes define as those student
who have taken AP course.
Here are some terminology and properties
associated with sub class relationships,
a super classes and UML
are sometimes called generalization with
sub classes called specialization and
some sub class relationship is said
to be complete if every
object in the super
class is in at least
one sub class and it's
incomplete if that's not
the case and incomplete is also
sometimes known as partial, a
sub class relationship is known
as disjoint if every object
is in at most one subclass.
In other words, we don't have
star on the left hand
side indicating that C2 objects
can be related to any number
of "C1" objects and, as
a reminder, star is an abbreviation
for "zero, dot, dot, star."
Many to many has no
restrictions on the relationships.
So that would be a star on both sides.
Pretty simple and the last
concept is the idea of complete relationships.
So a complete relationship is complementary to these others.
It says that every object
must participate in the relationship.
So we can have a complete one
to one, and that would
be one dot dot one on both sides.
We could have a complete many to
one, and that would
be on the left side
one dot dot star, and
on the right side one dot dot
one and, finally, a complete
many to many would be
one dot dot star on each side.
As a reminder, the default if
we don't specify the multiplicity
is a one dot dot one both sides.
So that would be a complete
one to one relationship.
Ok, we've finished with classes and with associations.
Now let's talk about association classes.
Association classes generalize the
notion of associations by allowing
us to put attributes on the
association itself and, again, we'll use our example.
So we already knew how to
specify that students apply to
colleges, but what if associated
with the application we wanted
to have, for example, the date
that they applied and maybe the decision of that application.
We don't really have a way
to do that without adding a
new construct, and that construct
is what's known as an association class.
So we can make a class and we'll just call it "App Info".
And it looks like a class,
it's got the box with the name at the top and the attributes.
And then we just attach that
box to the association,
and that tells us
that each instance of
the association between a student
and a college has additional information,
a date of that application and the decision of that application.
Now there's a couple of things I want to mention.
First of all, in a number
of examples, I'll probably leave
out the multiplicities on the ends of the associations.
That doesn't mean I'm assuming the default one one.
It's just when it's not relevant, I'm not going to focus on that aspect.
Now when we have students associated with colleges.
So we have a student here we have a college.
Then we have an association between those.
Now what we're saying is that
association is going to
have affiliated with it a date and a decision.
What we cannot describe in
UML is the possibility
of having more than one
relationship or association between the
same student and the same college.
So when we have an association
that assumes at most one
relationship between two objects.
So, for example, if we
wanted to add the possibility
that students could apply to
the same college multiple times so
maybe you know that want
to apply for separate majors.
That would actually have to be captured quite differently.
We'd have to add a separate
class that would for the
application information with separate
relationships to the students and colleges.
So this is a, in my
mind, a slight deficiency of UML.
Again, that and it only
captures, at most, one relationship
between the two specific
objects across the two classes.
Now, sometimes we can make
a design that has an association
class and it turns out
we didn't really need it and
we're going to come back to
multiplicities to see how this
can happen, so again let's
take a look at just generic classes C1 and C2.
Let's say that we have an
association between them and then we have an association class.
We'll just call it AC.
And that's gonna have some
attributes, we can call them A1 and A2 for now.
And of course, there's attributes
in C1 and C2 as well.
Let's suppose that the multiplicity
on, let's say the left
side is star so anything
goes, and on the right
side we have one to one.
So what that multiplicity says is
that each object Of C1
is related to at most one object of C2.
So, actually exactly one object in this case.
So we know that there's
going to be just one association for
each object of C1, and
if there's only going to
be one association actually we
could take these attributes and we
could put those attributes as part
of C1 instead of having
a separate association class, so
for example If this class
happened to be the student class,
and this was the college class,
and we insisted that each
student apply to exactly one
college then the attributes
we had down here, the date
and decision, could be moved
into the student class, because we
know they're only applying to one
college, so that would be
the date and the decision for
the one college they're applying to.
Furthermore, if we had zero
dot dot one, we can
still move these attributes here
and, in that case, if a
student was not involved in a
college - had not applied
to a college at all or, more
generally, an object of "C1"
was not related to any
object of "C2" then those
attributes would have the equivalent
of null values in them.
By the way, it is possible for
an association to be between a class and itself.
For example, we could have
our student class and maybe
we're going to have an association
called "sibling", a student
being associated with another student
because they're siblings, an association
between a class in itself
is written with a line tgat
just goes between the class and itself.
And then we could label that sibling.
And for multiplicities we can
assume that every student
has between 0 and an
arbitrary number of siblings lets
say, so we can put
a star on both ends of that association.
A more interesting association might
involve colleges where say
we have for every college
a flagship main campus.
But then some colleges have separate
branch or satellite campuses, so
that would be an association
between a college and itself
saying that one college is
a branch of another college.
Now let's think about the multiplicities here.
First of all, when we
have a self association, in UML
we're allowed to label the two ends of the association.
So I could, for example, say
on one end we have the
home campus.
And on another end we have the satellite campus.
And now with those labels
we can see the asymmetry and
that lets us get our associations right.
So let's say that every satellite
campus must have exactly one
home campus, so that would
be a one dot dot here
and every home campus can have
any number of satellite campuses.
Or actually, let's say something else.
Let's say every home campus
can have between zero and ten
satellite campuses be a
zero dot dot ten on that side of the self association.
Ok, we're finished with the first
three let's move on to sub classes.
For sub classes we're gonna do
a fairly large example that involves
students that we're gonna
separate into foreign students and domestic students.
We're also going to separately specify
students who have taken AP
classes and those will be our AP students.
So we're going to have the student
class as the top
of our hierarchy and the
student class will, again, have
the student ID, let's say
the student name, and GPA,
and we'll say the the student
ID is the primary key for
objects in that class, we're
going to have three sub classes,
one is going to be the
foreign students, we'll call it
foreign S, one is going
to be the domestic students and
then we're also going to
have a sub class for AP students.
and I'm going to assume that
you already know a little bit about sub classing from programming.
So the idea is that when
we have a sub class,
there are attributes that are
specific to the objects
that are in that sub class
and they'll inherit the attributes from their super class.
So we're gonna make student be a super class here.
And this is how we draw it,
with three sub classes here
for foreign student, domestic student, and AP student.
And we'll say that foreign students
have in addition to a
student ID, a student name and
GPA, a country that they come from.
We'll say that Domestic students
are going to have a state
that they come from and we'll
also say that they have
a Social Security number, which we
don't know that foreign students would necessarily have.
AP students, interestingly, is going to be empty.
It's not going to have any
additional attributes, but
the AP students are the
students that are going to
be allowed to have a
relationship with AP courses.
We'll say that the
AP course has a course number
and that's probably the primary key.
And maybe a title for the course and some units for the course.
And then when one of our AP students takes the course.
We'll call this "Association took".
We're going to have an association class
that goes along with that, that's
going to have the information,
let's called it "AP info", about
them taking that particular AP
class and we'll say that
association class has for
example the year that they
took the class and maybe the grade that they got in the class.
And lastly let's add some multiplicities.
Let's say that AP students
can take between one and
ten AP classes but they
taken at least one to
be an AP student and let's
say that every course has taken
by at least one student and
arbitrary number of students.
So this is one of the
biggest UML diagrams we've seen so far.
Again, this is a superclass up here.
And we have our subclasses down here.
And then we also have an
association, and an association class, and some multiplicities.
And again notice that
is ok that there are
no attributes in the AP
student sub class that sub
classes define as those student
who have taken AP course.
Here are some terminology and properties
associated with sub class relationships,
a super classes and UML
are sometimes called generalization with
sub classes called specialization and
some sub class relationship is said
to be complete if every
object in the super
class is in at least
one sub class and it's
incomplete if that's not
the case and incomplete is also
sometimes known as partial, a
sub class relationship is known
as disjoint if every object
is in at most one subclass.
In other words, we don't have
การแปล กรุณารอสักครู่..