-
Notifications
You must be signed in to change notification settings - Fork 1
bedidentityModel
in the simple model, we want to track free beds on a by-station basis. For this, each station belongs to a hospital (many-to-one relationship) and each station has multiple bed counts (one-to-many relationship). Furthermore, each bed count has exactly one bed type related, but one bed type can be related to multiple bed counts. Below, we will discuss each of the aforementioned data types in detail. Each data type entity is identified by a randomly generated type 4 UUID, which is also the primary key in the corresponding table.
table name: hospital
Fields:
-
id
: the uniqueUUID
. -
name
: the name of the hospital, asVARCHAR (255) NOT NULL
. -
max_capacity
: the maximum bed capacity (accumulated) of a hospital, represented asSMALLINT NOT NULL
and should always be> 0
. -
lat
: theString
-representation of the geolocation latitude, represented asVARCHAR (255)
. Should be nullable to allow for missing data. -
long
: theString
-representation of the geolocation longitude, represented asVARCHAR (255)
. Should be nullable to allow for missing data.
table name: station_type
Fields:
-
id
: the uniqueUUID
. -
name
: the name station type, asVARCHAR (255) NOT NULL
.
Implementation remark:
This should be implemented as enum
in the business logic. A station_type
with name UNKNOWN
should be implemented.
table name: station
Fields:
-
id
: the uniqueUUID
. -
name
: the name of the station, asVARCHAR (255) NOT NULL
. -
hospital_id
: the foreign key to the correspondinghospital
. This database column should be indexed. Not nullable. -
station_type_id
: the foreign key to the correspondingstation_type
. This database column should be indexed. Not nullable.
table name: bed_type
Fields:
-
id
: the uniqueUUID
-
name
: the name of the bed type, asVARCHAR (255) NOT NULL
. This database column should be indexed.
Implementation remark:
This should be implemented as enum
in the business logic.
table name: bed_type_count
Fields:
-
id
: the uniqueUUID
. -
max_capacity
: the maximum bed count (accumulated) of this type in the corresponding station, represented asSMALLINT NOT NULL
and should always be> 0
. -
current_occupied
: the number of currently occupied beds (accumulated) of this type in the corresponding station, represented asSMALLINT NOT NULL
and should always be>= 0
and<= max_count
. -
occupied_last_changed
: the UNIX-timestamp when thecurrent_occupied
attribute was last changed asBIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW() * 1000)
. -
station_id
: the foreign key to the correspondingstation
. This database column should be indexed. Not nullable. -
bed_type_id
: the foreign key to the correspondingbed_type
. This database column should be indexed. Not nullable.
Implementation detail:
The occupied_last_changed
must always be updated when current_occupied
is changed.