regenerate it
- User
regenerate it
Assistant
Sure, let's refine the PlantUML script to better represent the relationships and attributes for the House Rental Management System. Here's the updated script:
@startuml skinparam defaultFontName Helvetica ' Entities entity "User" as User { + user_id : int (PK) -- + email : varchar (Unique) + password : varchar + role : enum (tenant, owner, admin) + created_at : datetime + updated_at : datetime } entity "Tenant" as Tenant { + user_id : int (FK) -- + first_name : varchar + last_name : varchar + phone_number : varchar } entity "Owner" as Owner { + user_id : int (FK) -- + business_name : varchar + phone_number : varchar } entity "Admin" as Admin { + user_id : int (FK) -- ' No additional attributes } entity "House" as House { + house_id : int (PK) -- + owner_id : int (FK) + address : varchar + price : decimal + description : text + status : enum (available, booked, pending, deleted) + image_url : varchar + created_at : datetime + updated_at : datetime } entity "Booking" as Booking { + booking_id : int (PK) -- + tenant_id : int (FK) + house_id : int (FK) + booking_date : datetime + start_date : datetime + end_date : datetime + status : enum (pending, confirmed, rejected) + confirmation_date : datetime } ' Relationships ' User Subtypes User "1" -- "1" Tenant : "is a" User "1" -- "1" Owner : "is a" User "1" -- "1" Admin : "is a" ' Owner <-> House (1:N) Owner "1" -- "*" House : "owns" House : owner_id (FK) --> Owner : user_id (PK) ' Tenant <-> Booking (1:N) Tenant "1" -- "*" Booking : "makes" Booking : tenant_id (FK) --> Tenant : user_id (PK) ' House <-> Booking (1:N) House "1" -- "*" Booking : "is booked in" Booking : house_id (FK) --> House : house_id (PK) ' Admin permissions (via role in User) note right of Admin Admin can access all entities\n(via role in User table) end note @endumlHow to Use This Script
-
Copy the script above into a PlantUML editor:
- Online: Use PlantUML Live Editor.
- Desktop: Install PlantUML and use tools like Visual Studio Code with the PlantUML extension.
-
Generate the Diagram:
- The script will render an ER diagram showing entities, attributes, and relationships.
Key Features of the Diagram
- Inheritance:
Useris the supertype withTenant,Owner, andAdminas subtypes. - Foreign Keys:
House.owner_idlinks toUser.user_id(filtered byrole = "owner").Booking.tenant_idlinks toUser.user_id(filtered byrole = "tenant").Booking.house_idlinks toHouse.house_id.
- Cardinalities:
Owner→House: 1-to-many.Tenant→Booking: 1-to-many.House→Booking: 1-to-many.
- Admin Permissions: Noted as a comment since it’s enforced via the
rolefield inUser.
Screenshot of the Diagram
Here’s a rough textual representation of how the diagram will look:
+-------------------+ | User | | (PK) user_id | | email (Unique) | | password | | role (ENUM) | | created_at | | updated_at | +-------------------+ | | 1 | +-----------+ +-----------+ +-----------+ | Tenant | | Owner | | Admin | | (FK) user_id | (FK) user_id | (FK) user_id | | first_name | business_name | | | last_name | phone_number | | | phone_number| | | +-----------+ +-----------+ +-----------+ +-------------------+ | House | | (PK) house_id | | owner_id (FK) | | address | | price | | description | | status (ENUM) | | image_url | | created_at | | updated_at | +-------------------+ | | 1 * | |--------------| "owns" +-------------------+ | Booking | | (PK) booking_id | | tenant_id (FK) | | house_id (FK) | | booking_date | | start_date | | end_date | | status (ENUM) | | confirmation_date | +-------------------+ | | | | | | | | +-----------+ +-----------+ | Tenant | | House | +-----------+ +-----------+This script should give you a clear and accurate ER diagram for your House Rental Management System. If you need further adjustments, feel free to ask! 😊
-