-
Notifications
You must be signed in to change notification settings - Fork 0
Database
Oliver Pennery edited this page Apr 22, 2021
·
6 revisions
| Syntax | Data Type | Description |
|---|---|---|
| ID | Long | Primary Key |
| Name | String | Name of building |
| Syntax | Data Type | Description |
|---|---|---|
| ID | Long | Primary Key |
| Name | String | Name of building |
| BuildingId | Long | Foreign key of building |
| Syntax | Data Type | Description |
|---|---|---|
| ID | Long | Primary Key[IOT ID] |
| Description | String | Description of Device |
| RoomId | Long | Foreign key of Room |
| Syntax | Data Type | Description |
|---|---|---|
| ID | Long | Primary Key |
| Date | Date | Date and time of reading |
| CO2 | Int | CO2 reading |
| SensorId | Long | Foreign key of Sensor |
Foreign keys are one to many in a tree stuct building ->> room ->> device ->> reading
how the parent is defined in code
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JsonBackReference
@Getter
@Setter
private Room room;
how the child is defined in code
@OneToMany(mappedBy = "sensor", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JsonManagedReference
@Setter
private Set<Reading> readings;