0% found this document useful (0 votes)
5 views

OpenEnded

The document is a lab report for CSE 2302, detailing the requirement analysis for a Property Rental Platform database. It outlines the entities, their attributes, and relationships, along with SQL queries for data retrieval and manipulation. The report includes database and table creation instructions, data insertion, and various SQL query examples with explanations.

Uploaded by

thritu2020
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

OpenEnded

The document is a lab report for CSE 2302, detailing the requirement analysis for a Property Rental Platform database. It outlines the entities, their attributes, and relationships, along with SQL queries for data retrieval and manipulation. The report includes database and table creation instructions, data insertion, and various SQL query examples with explanations.

Uploaded by

thritu2020
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Course Code: CSE 2302

Course Title: Database Management Systems Lab


Lab Report 2

Submitted by:

Student Name: Tahmina Akter Ritu

ID: 231014107

Section: 2

Submitted to:
Jannatul Ferdous Ruma

Department of Computer Science and Engineering (CSE)


University of Liberal Arts Bangladesh
Requirement Analysis for ER DIAGRAM

The Property Rental Platform is for storing, updating, deleting and retrieving information for
property rentals. The Entities with their attributes are-
 Property: Id (PK), Address, Bedrooms, Bathrooms, SquareFeet, IsAvailable, OwnerId
(FK), PropertyManagerId (FK).
 Owner: Id (PK), FirstName, LastName, Email, Phone.
 Tenant: Id (PK), FirstName, LastName, Email, Phone.
 LeaseAgreement: Id (PK), PropertyId (FK), TenantId (FK), StartDate, EndDate,
RentAmount
 Payment: Id (PK), TeanatId (FK), LeaseAgreementId (FK), Date, Amount.
 PropertyManager: Id (PK), FirstName, LastName, Email, Phone.
 MaintenanceRequest: Id (PK), PropertyId (FK), TenantId (FK), Date, Issue,
IsResolved.

Entity Relationships:

 MaintenanceRequest – Tenant (reportedBy): A tenant can report many maintenance


requests (one-to-many) but each maintenance request is reported by only one tenant.
 MaintenanceRequest – Property (concerns): A property can have many maintenance
requests (one-to-many) but each maintenance request is tied to one property.
 Property – Owner (isOwnedBy): An owner can own multiple properties (one-to-many)
but each property belongs to only one owner.
 Property – PropertyManager (isManagedBy): A property manager can manage
multiple properties (one-to-many) but each property is managed by only one property
manager.
 LeaseAgreement – Property (relatesTo): A property can have multiple lease
agreements over time (one-to-many) but each lease agreement relates to one property.
 LeaseAgreement – Tenant (makes): A tenant can enter into multiple lease agreements
(one-to-many) but each lease agreement is associated with one tenant.
 Payment – LeaseAgreement (covers): A lease agreement can have multiple payments
(one-to-many) but each payment is linked to one lease agreement.
 Payment – Tenant (involves): A tenant can make many payments (one-to-many) but
each payment is made by only one tenant.
ER Diagram:
Database Creation:
 Create database named PropertyRentalPlatform.

Table Creation:
 Create table Owner.

 Create table PropertyManager.

 Create table Property.


 Create table Tenant.

 Create table MaintenanceRequest.

 Create table LeaseAgreement.

 Create table Payment.

 Show all tables.


Insertion of Data:

 Inserting data into Owner table.

 Inserting data into PropertyManager table.


 Inserting data into Property table.

 Inserting data into Tenant table.


 Inserting data into MaintenanceRequest table.

 Inserting data into LeaseAgreement table.


 Inserting data into Payment table.

SQL Queries with Output:

1. Properties with more than 3 bedrooms

Explanation: The SQL query retrieves the "Address" and "Bedrooms" columns from the
"Property" table. But only for properties where the number of bedrooms is greater than 3. It
filters the data based on the condition "Bedrooms > 3," ensuring only properties with more than
3 bedrooms are selected.

2. Total rent amount of all lease agreements and the average square feet of all properties
Explanation: The SQL query calculates the total rent amount (RentAmount) by summing up all
values in the RentAmount column and finds the average square footage (SquareFeet) by
computing the average of all values in the SquareFeet column. It pulls data from two tables,
LeaseAgreement and Property.

3. Get all unresolved maintenance requests with tenant details

Explanation: This SQL query selects the issue from the MaintenanceRequest table along with
the first and last names of tenants from the Tenant table. It joins both tables based on the
TenantId and Id fields and filters the results to only include unresolved maintenance requests
(where IsResolved is FALSE).

4. Find Tenants Who Paid Rent in January

Explanation: This SQL query retrieves the first and last names of tenants along with the
payment date and amount by joining the Tenant and Payment tables on the TenantId. It filters the
results to include only payments made between January 1st 2024 and January 31st 2024.

5. List the first and last names of tenants who have signed lease agreements with a rent amount
greater than 15,000.
Explanation: This SQL query retrieves the first and last names of tenants whose IDs match
those listed in the LeaseAgreement table where the rent amount is greater than 15,000. It uses a
subquery to find TenantIds from LeaseAgreement with rent amounts above this threshold then
selects the corresponding tenants.

6. List all properties along with the tenant's first and last name

Explanation: This SQL query retrieves the address of properties along with the first and last
names of tenants. It joins the "Property" table with the "LeaseAgreement" table on the property
ID and then joins the "LeaseAgreement" table with the "Tenant" table on the tenant ID to get the
relevant data.

7. Left join between Property and Owner

Explanation: This SQL query selects details from the "Property" table including the property
ID, address, bedrooms and owner ID. It also retrieves the owner's first and last names from the
"Owner" table using a LEFT JOIN ensuring all properties are shown even if they don't have an
associated owner.
8. Count the number of maintenance requests for each property

Explanation: This SQL query retrieves the address of each property and counts the number of
maintenance requests associated with each property. It joins the "Property" table with the
"MaintenanceRequest" table using the property ID then groups the results by property ID to get
the count of requests per property.

9. Find all properties that have tenants but are marked as unavailable

Explanation: This SQL query retrieves the address and availability status of properties that are
not available along with the first and last names of tenants associated with those properties. It
joins the "Property", "LeaseAgreement" and "Tenant" tables to connect property details with
tenant information filtering for unavailable properties.

10. Find Properties that are available


Explanation: This SQL query retrieves all records from the "Property" table where the
"IsAvailable" column has a value of true. Which means it selects properties that are currently
available. The asterisk (*) indicates that all columns for those properties will be returned in the
result set.

You might also like