is it allowed to leave an attribute empty in the Entity–relationship model?

82 views Asked by At

Take a look at the ER diagram below:

enter image description here

Is it allowed to leave an attribute empty in the Entity–relationship model? Null values are not allowed.

So would it be possible for a person to have no pet according to the ER diagram?

1

There are 1 answers

0
Christophe On

This diagram leaves the answer to your question unspecified: There is no authoritative specification for ERD that would prevent or - on contrary - allow attributes to be null. Nor are there standard types defined for ERD. For instance if pet is a string, would and empty string be null or not?

In practice, some modellers use SQL types and use the database conventions and the suffix NOT NULL. Some others use the suffix N for fields that can be NULL. Finally, some use other textual (optional vs. mandatory) or graphical elements (e.g. bold vs non bold) to document attribute constraints. All this leaves a lot of room for ambiguity.

If you want to be explicit on the minimum and maximum number of pets, a better alternative is to define an entity Pet and define a relationship between Person and Pet, documenting explicitly the cardinality (total participation vs partial participation and whether there can be at most one pet vs many pets):

enter image description here

Or you switch to UML: in UML the default multiplicity of an attribute is [1] (value should be present), but you are allowed to set it to [0..1] to say that there doesn't have to be a value.