Database Diagram
A database diagram seems to be an unofficial diagram mostly based on a simplified Class Diagram with some semantic changes.
A class ποΈ, such as Person
, is a structured data definition. It has attributes π such as name
which has the type String
.
A record π« is a concrete instance of a class, e.g., we gave concrete values to each attribute of the class (ex: Person(id=1, name="John Doe")).
Some attributes such as id
are special attributes called identifiers. They are used to identify a record (e.g., given an ID, we can find a person).
Associations π, Generalizations π¨βπ©βπ§βπ¦, and multiplicity π’ are the same as for classes diagrams.
π In practice, identifiers are usually called keys π while a key is actually the implementation (ex: in SQL) of an identifier.
π We often use OCL along the diagram to express constraints.
My notes
Identifiers
Rules π
- Each class must have an identifier
- Identifiers are unique and not null (by design)
- An identifier can be composed of multiple attributes
Diagram π¨
-
# attr
orattr
: an attribute part of the primary key -
* attr
: an attribute that can potentially become a key -
β attr
: an artificial key
Both primary keys and artificial keys are explained here.
Changes with class diagrams
Diagram π¨
- There is no concept of
visibility
(#attr does not mean protected) - There is no concept of
class attributes
(attr is not a class attribute) - There are usually no
operations
. If there are, it means we will use PL/SQL or another procedural language to code them.