Reputation: 59
Someone could help me please?
I want to make a class diagram in UML, and I have CATEGORY class which can have SUBCATEGORIES and so on. How can I manage it in class diagram, thus in mysql database?
Thanks in advance
Upvotes: 0
Views: 1106
Reputation: 5673
A hierarchy (or tree) of categories is modeled with a recursive one-to-many association, which associates the Category
class with itself, as shown in the following diagram:
Such an Information Design Model can be transformed into an OOP Class Model and into an SQL Table Model, like so:
Notice how the superCategory
column is designated as a foreign key referencing the categories
table in the table model: by a UML dependency arrow stereotyped as «fk».
I hope you can figure out yourself how to code the SQL Table Model in an SQL Create Table
statement.
p.s.: For more about how to model databases with UML CLass Diagrams seee https://stackoverflow.com/a/21394401/2795909
Upvotes: 2