SlideShare a Scribd company logo
1 of 19
A DATA MODEL FOR
LISTING
APARTMENTS
BY:
POOJA, ADITI, TRANG
& KAREN
OUR GOALS
• Manage the information from user table, unit table, parent unit table and leasing
information table
• Track for available units
• Keep the information up to date
• Create database to run the business
ERD
UNIT TABLE
PARENT UNIT TABLE
USER TABLE
LEASING INFO TABLE
INSERT RECORD INTO UNIT TABLE
• SELECT * FROM unit;
• INSERT INTO unit
• VALUES (22, 21, 4, '2BD/2BR - The Colorado,
Newly Updated!', 2, 2, 1, '12/6/2019',
'1/1/2020', 'TRUE', 'Unit has been updated
with brand-new wood flooring throughout.
Kitchen has new granite counters and
appliances. Will not last long!')
LEASING INFO TABLE REFLECT NEW RENTAL
INFORMATION
INSERT RECORD INTO PARENT UNIT TABLE
SELECT * FROM mydb.parent_unit;
INSERT INTO parent_unit
VALUES(101, 6, 1, 3, 12, 1, 1, 1, 1, 1, 1)
INSERT DATA STORED PROCEDURE
DELIMITER |
CREATE PROCEDURE add_new_user_interested_unit (in W_User_ID
int(11), in W_Unit_ID int(11))
BEGIN DECLARE W_Parent_Unit_ID int(11);
DECLARE W_Unit_Leasing_ID varchar(50);
SELECT Leasing_Info_ID ,Parent_unit_ID INTO W_Unit_Leasing_ID,
W_Parent_Unit_ID
FROM unit WHERE ID = W_Unit_ID;
INSERT into user_interested_unit
VALUES(W_User_ID,W_Unit_ID,W_Unit_Leasing_ID,W_Parent_Unit_I
D);
END | DELIMITER ;
CALL add_new_user_interested_unit(44526,8);
SELECT * FROM user_interested_unit;
UPDATE DATA STORED PROCEDURE
DELIMITER |
CREATE PROCEDURE update_user_interested_unit
(in W_User_ID int(11), in W_New_User_ID int(11))
BEGIN UPDATE user_interested_unit
SET User_ID = W_New_User_ID
WHERE User_ID = W_User_ID;
END | DELIMITER ;
CALL update_user_interested_unit(7172,9841);
SELECT * FROM user_interested_unit;
REPORTS GENERATION
• SQL Query to show the Average Rent for short term leasing and Long Term Leasing.
• SQL Query to show the Average Rent for short term leasing and Long Term Leasing for the
Total number of Bedrooms.
• Query to display the Parent units ID that has wheelchair accessibility and Bus stop
accessibility.
• Query showing the number of Total Floors which has minimum 2 elevators in an apartment
or Unit
• Query to display the Unit Description which starts with ‘Excellent’ and ‘Great’ with their
Parent unit ID.
CONTINUED….
• Query to display the Sum of Admin Fee, Security Deposit, Lease Termination
Amount as Processing Cost.
• Write A SQL Query To Print All User Details From The User Table Order By
FIRST_NAME Ascending.
• Write A SQL Query To Fetch The Total number of Buildings In The Parent Unit
where Parent Unit number is ‘10’.
SQL QUERY TO SHOW THE AVERAGE RENT FOR SHORT TERM
LEASING AND LONG TERM LEASING
Select Leasing_Type,
AVG(Rent_for_short_term_Leasing) as 'Avg short term’,
AVG(Rent_for_long_term_Leasing) as 'Avg long term'
From leasing_info
join unit
group by Leasing_Type
SQL QUERY TO SHOW THE AVERAGE RENT FOR SHORT TERM LEASING AND LONG
TERM LEASING FOR THE TOTAL NUMBER OF BEDROOMS
Select Leasing_Type, Num_of_Bedroom,
AVG(Rent_for_short_term_Leasing) as 'Avg short term',
AVG(Rent_for_long_term_Leasing) as 'Avg long term'
From leasing_info li
Join unit on li.id = unit.Leasing_Info_ID
Group by Leasing_Type,Num_of_Bedroom
QUERY SHOWING THE NUMBER OF TOTAL FLOORS WHICH HAS MINIMUM 2
ELEVATORS IN AN APARTMENT OR UNIT.
Select Number_of_Elevators,Total_Floors,count(*)
From parent_unit
Where Total_Floors >=2
Group by Number_of_Elevators,Total_Floors
Order by count(*) desc , Total_Floors desc, Number_of_Elevators
desc
WRITE A SQL QUERY TO PRINT ALL USER DETAILS FROM THE USER TABLE ORDER
BY FIRST_NAME ASCENDING.
Select * from User
Order By FIRST_NAME asc;
Thank You

More Related Content

Similar to A Data Model for Listing Apartments

Chvac software tutorial
Chvac software tutorialChvac software tutorial
Chvac software tutorialAlexBiaco
 
Database Design Project-Oracle 11g
Database Design  Project-Oracle 11g Database Design  Project-Oracle 11g
Database Design Project-Oracle 11g Sunny U Okoro
 
Pega poc | Pega projects
Pega poc | Pega projectsPega poc | Pega projects
Pega poc | Pega projectsAshock Roy
 
Garrage management system
Garrage management system Garrage management system
Garrage management system Prateek Pandey
 
Presentation v mware roi tco calculator
Presentation   v mware roi tco calculatorPresentation   v mware roi tco calculator
Presentation v mware roi tco calculatorsolarisyourep
 
BUS 145 – Database Project – Part 2 Build and Test The.docx
BUS 145 – Database Project – Part 2 Build and Test The.docxBUS 145 – Database Project – Part 2 Build and Test The.docx
BUS 145 – Database Project – Part 2 Build and Test The.docxRAHUL126667
 
ENERGY STAR qualification process and marketing strategy
ENERGY STAR qualification process and marketing strategyENERGY STAR qualification process and marketing strategy
ENERGY STAR qualification process and marketing strategyclaremont mckenna college
 
The ultimate-guide-to-sql
The ultimate-guide-to-sqlThe ultimate-guide-to-sql
The ultimate-guide-to-sqlMcNamaraChiwaye
 
Part1 of SQL Tuning Workshop - Understanding the Optimizer
Part1 of SQL Tuning Workshop - Understanding the OptimizerPart1 of SQL Tuning Workshop - Understanding the Optimizer
Part1 of SQL Tuning Workshop - Understanding the OptimizerMaria Colgan
 
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docxMSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docxgilpinleeanna
 
Modernization of Northwood Housing Society using Salesforce CRM
Modernization of Northwood Housing Society using Salesforce CRMModernization of Northwood Housing Society using Salesforce CRM
Modernization of Northwood Housing Society using Salesforce CRMKaushik Rajan
 
Modernization of northwood housing society using salesforce crm
Modernization of northwood housing society using salesforce crmModernization of northwood housing society using salesforce crm
Modernization of northwood housing society using salesforce crmSindhujanDhayalan
 
VMworld 2013: Leveraging IT Financial Transparency to Drive Transformation
VMworld 2013: Leveraging IT Financial Transparency to Drive TransformationVMworld 2013: Leveraging IT Financial Transparency to Drive Transformation
VMworld 2013: Leveraging IT Financial Transparency to Drive TransformationVMworld
 
Database Design and Development 2022 00185501.docx
Database Design and Development 2022 00185501.docxDatabase Design and Development 2022 00185501.docx
Database Design and Development 2022 00185501.docxkiokosoft
 

Similar to A Data Model for Listing Apartments (20)

Chvac software tutorial
Chvac software tutorialChvac software tutorial
Chvac software tutorial
 
Database Design Project-Oracle 11g
Database Design  Project-Oracle 11g Database Design  Project-Oracle 11g
Database Design Project-Oracle 11g
 
Pega poc | Pega projects
Pega poc | Pega projectsPega poc | Pega projects
Pega poc | Pega projects
 
Garrage management system
Garrage management system Garrage management system
Garrage management system
 
Presentation v mware roi tco calculator
Presentation   v mware roi tco calculatorPresentation   v mware roi tco calculator
Presentation v mware roi tco calculator
 
geo spatial innovation
geo spatial innovationgeo spatial innovation
geo spatial innovation
 
BUS 145 – Database Project – Part 2 Build and Test The.docx
BUS 145 – Database Project – Part 2 Build and Test The.docxBUS 145 – Database Project – Part 2 Build and Test The.docx
BUS 145 – Database Project – Part 2 Build and Test The.docx
 
ENERGY STAR qualification process and marketing strategy
ENERGY STAR qualification process and marketing strategyENERGY STAR qualification process and marketing strategy
ENERGY STAR qualification process and marketing strategy
 
The ultimate-guide-to-sql
The ultimate-guide-to-sqlThe ultimate-guide-to-sql
The ultimate-guide-to-sql
 
Energy Star Application Process Overview
Energy Star Application Process OverviewEnergy Star Application Process Overview
Energy Star Application Process Overview
 
Part1 of SQL Tuning Workshop - Understanding the Optimizer
Part1 of SQL Tuning Workshop - Understanding the OptimizerPart1 of SQL Tuning Workshop - Understanding the Optimizer
Part1 of SQL Tuning Workshop - Understanding the Optimizer
 
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docxMSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
Modernization of Northwood Housing Society using Salesforce CRM
Modernization of Northwood Housing Society using Salesforce CRMModernization of Northwood Housing Society using Salesforce CRM
Modernization of Northwood Housing Society using Salesforce CRM
 
Modernization of northwood housing society using salesforce crm
Modernization of northwood housing society using salesforce crmModernization of northwood housing society using salesforce crm
Modernization of northwood housing society using salesforce crm
 
VMworld 2013: Leveraging IT Financial Transparency to Drive Transformation
VMworld 2013: Leveraging IT Financial Transparency to Drive TransformationVMworld 2013: Leveraging IT Financial Transparency to Drive Transformation
VMworld 2013: Leveraging IT Financial Transparency to Drive Transformation
 
BNA Income Tax Planner Product Information
BNA Income Tax Planner Product InformationBNA Income Tax Planner Product Information
BNA Income Tax Planner Product Information
 
BNA Income Tax Planner Data Sheet
BNA Income Tax Planner Data SheetBNA Income Tax Planner Data Sheet
BNA Income Tax Planner Data Sheet
 
Database Design and Development 2022 00185501.docx
Database Design and Development 2022 00185501.docxDatabase Design and Development 2022 00185501.docx
Database Design and Development 2022 00185501.docx
 

Recently uploaded

Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?RemarkSemacio
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证acoha1
 
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证acoha1
 
How to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data AnalyticsHow to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data AnalyticsBrainSell Technologies
 
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...ThinkInnovation
 
Bios of leading Astrologers & Researchers
Bios of leading Astrologers & ResearchersBios of leading Astrologers & Researchers
Bios of leading Astrologers & Researchersdarmandersingh4580
 
社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token PredictionNABLAS株式会社
 
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...ssuserf63bd7
 
Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024patrickdtherriault
 
obat aborsi Bontang wa 082135199655 jual obat aborsi cytotec asli di Bontang
obat aborsi Bontang wa 082135199655 jual obat aborsi cytotec asli di  Bontangobat aborsi Bontang wa 082135199655 jual obat aborsi cytotec asli di  Bontang
obat aborsi Bontang wa 082135199655 jual obat aborsi cytotec asli di Bontangsiskavia95
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...Bertram Ludäscher
 
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...mikehavy0
 
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...Payal Garg #K09
 
jll-asia-pacific-capital-tracker-1q24.pdf
jll-asia-pacific-capital-tracker-1q24.pdfjll-asia-pacific-capital-tracker-1q24.pdf
jll-asia-pacific-capital-tracker-1q24.pdfjaytendertech
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Klinik kandungan
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshareraiaryan448
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRajesh Mondal
 
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTS
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTSDBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTS
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTSSnehalVinod
 
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarjSCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarjadimosmejiaslendon
 

Recently uploaded (20)

Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?
 
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get CytotecAbortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
 
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
 
How to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data AnalyticsHow to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data Analytics
 
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
 
Bios of leading Astrologers & Researchers
Bios of leading Astrologers & ResearchersBios of leading Astrologers & Researchers
Bios of leading Astrologers & Researchers
 
社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction
 
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
 
Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024
 
obat aborsi Bontang wa 082135199655 jual obat aborsi cytotec asli di Bontang
obat aborsi Bontang wa 082135199655 jual obat aborsi cytotec asli di  Bontangobat aborsi Bontang wa 082135199655 jual obat aborsi cytotec asli di  Bontang
obat aborsi Bontang wa 082135199655 jual obat aborsi cytotec asli di Bontang
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
 
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
 
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...
 
jll-asia-pacific-capital-tracker-1q24.pdf
jll-asia-pacific-capital-tracker-1q24.pdfjll-asia-pacific-capital-tracker-1q24.pdf
jll-asia-pacific-capital-tracker-1q24.pdf
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshare
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for Research
 
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTS
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTSDBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTS
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTS
 
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarjSCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
 

A Data Model for Listing Apartments

  • 1. A DATA MODEL FOR LISTING APARTMENTS BY: POOJA, ADITI, TRANG & KAREN
  • 2. OUR GOALS • Manage the information from user table, unit table, parent unit table and leasing information table • Track for available units • Keep the information up to date • Create database to run the business
  • 3. ERD
  • 8. INSERT RECORD INTO UNIT TABLE • SELECT * FROM unit; • INSERT INTO unit • VALUES (22, 21, 4, '2BD/2BR - The Colorado, Newly Updated!', 2, 2, 1, '12/6/2019', '1/1/2020', 'TRUE', 'Unit has been updated with brand-new wood flooring throughout. Kitchen has new granite counters and appliances. Will not last long!')
  • 9. LEASING INFO TABLE REFLECT NEW RENTAL INFORMATION
  • 10. INSERT RECORD INTO PARENT UNIT TABLE SELECT * FROM mydb.parent_unit; INSERT INTO parent_unit VALUES(101, 6, 1, 3, 12, 1, 1, 1, 1, 1, 1)
  • 11. INSERT DATA STORED PROCEDURE DELIMITER | CREATE PROCEDURE add_new_user_interested_unit (in W_User_ID int(11), in W_Unit_ID int(11)) BEGIN DECLARE W_Parent_Unit_ID int(11); DECLARE W_Unit_Leasing_ID varchar(50); SELECT Leasing_Info_ID ,Parent_unit_ID INTO W_Unit_Leasing_ID, W_Parent_Unit_ID FROM unit WHERE ID = W_Unit_ID; INSERT into user_interested_unit VALUES(W_User_ID,W_Unit_ID,W_Unit_Leasing_ID,W_Parent_Unit_I D); END | DELIMITER ; CALL add_new_user_interested_unit(44526,8); SELECT * FROM user_interested_unit;
  • 12. UPDATE DATA STORED PROCEDURE DELIMITER | CREATE PROCEDURE update_user_interested_unit (in W_User_ID int(11), in W_New_User_ID int(11)) BEGIN UPDATE user_interested_unit SET User_ID = W_New_User_ID WHERE User_ID = W_User_ID; END | DELIMITER ; CALL update_user_interested_unit(7172,9841); SELECT * FROM user_interested_unit;
  • 13. REPORTS GENERATION • SQL Query to show the Average Rent for short term leasing and Long Term Leasing. • SQL Query to show the Average Rent for short term leasing and Long Term Leasing for the Total number of Bedrooms. • Query to display the Parent units ID that has wheelchair accessibility and Bus stop accessibility. • Query showing the number of Total Floors which has minimum 2 elevators in an apartment or Unit • Query to display the Unit Description which starts with ‘Excellent’ and ‘Great’ with their Parent unit ID.
  • 14. CONTINUED…. • Query to display the Sum of Admin Fee, Security Deposit, Lease Termination Amount as Processing Cost. • Write A SQL Query To Print All User Details From The User Table Order By FIRST_NAME Ascending. • Write A SQL Query To Fetch The Total number of Buildings In The Parent Unit where Parent Unit number is ‘10’.
  • 15. SQL QUERY TO SHOW THE AVERAGE RENT FOR SHORT TERM LEASING AND LONG TERM LEASING Select Leasing_Type, AVG(Rent_for_short_term_Leasing) as 'Avg short term’, AVG(Rent_for_long_term_Leasing) as 'Avg long term' From leasing_info join unit group by Leasing_Type
  • 16. SQL QUERY TO SHOW THE AVERAGE RENT FOR SHORT TERM LEASING AND LONG TERM LEASING FOR THE TOTAL NUMBER OF BEDROOMS Select Leasing_Type, Num_of_Bedroom, AVG(Rent_for_short_term_Leasing) as 'Avg short term', AVG(Rent_for_long_term_Leasing) as 'Avg long term' From leasing_info li Join unit on li.id = unit.Leasing_Info_ID Group by Leasing_Type,Num_of_Bedroom
  • 17. QUERY SHOWING THE NUMBER OF TOTAL FLOORS WHICH HAS MINIMUM 2 ELEVATORS IN AN APARTMENT OR UNIT. Select Number_of_Elevators,Total_Floors,count(*) From parent_unit Where Total_Floors >=2 Group by Number_of_Elevators,Total_Floors Order by count(*) desc , Total_Floors desc, Number_of_Elevators desc
  • 18. WRITE A SQL QUERY TO PRINT ALL USER DETAILS FROM THE USER TABLE ORDER BY FIRST_NAME ASCENDING. Select * from User Order By FIRST_NAME asc;