Database Systems for Boston House Price Prediction | Bài báo cáo học phần Database Systems | Đại học Quốc gia Hà Nội
Housing is one of the most basic demands of human life, along with food, water, and other necessities. As people's living circumstances improved, demand for housing increased rapidly. Housing markets have a favorable impact on a country's currency, which is a significant factor in the national economy. Numerous factors influence housing sales prices, including the size of the property, its location, the materials used in construction, the age of the property, the number of bedrooms and garages, and so on. Tài liệu giúp bạn tham khảo, ôn tập và đạt kết quả cao. Mời bạn đón xem.
Preview text:
Group 12 23/12/2023
VIETNAM NATIONAL UNIVERSITY, HANOI INTERNATIONAL SCHOOL
----------------*****-----------------
FINAL REPORT: DATABASE SYSTEMS
Topic: Database Systems for Boston House Price Prediction Lecturer
Nguyễn Trần Đình Long Class INS 2055-01 Phạm Hải Đăng 20070701 Nguyễn Đức Anh 20070668 Nguyễn Minh Hoàng 20070720 Hanoi, Dec Group 12 23/12/2023 Table of Contets: Contents I.
Introduction.............................................................................................................5 II.
Data dictionary........................................................................................................5 III.
Analyzing and draw the ERD diagram....................................................................7 IV.
Relational Schema...................................................................................................9 V. Build a
database using SQL Sever........................................................................10 VI. Business
Questions..................................................................................................15
VII.Conclusion:..............................................................................................................19
VIII. Reference...............................................................................................................20 lOMoARcPSD|47206417 Group 12 23/12/2023 I. Introduction:
Housing is one of the most basic demands of human life, along with food, water, and
other necessities. As people's living circumstances improved, demand for housing
increased rapidly. Housing markets have a favorable impact on a country's currency, which
is a significant factor in the national economy. Numerous factors influence housing sales
prices, including the size of the property, its location, the materials used in construction,
the age of the property, the number of bedrooms and garages, and so on.
A house-price prediction model can provide numerous benefits to home purchasers,
property investors, and home builders. This model may provide a wealth of information
and expertise to home purchasers, property investors, and home builders, such as the
valuation of current market house prices, which will assist them in determining house
pricing. Meanwhile, this model can assist potential purchasers in determining the features
of a property that are appropriate for their budget.
In this project, we will develop and evaluate the performance and the predictive
power of a model trained and tested on data collected from houses in Boston’s suburbs.
Once we get a good fit, we will use this model to predict the monetary value of a house
located at the Boston’s area. A model like this would be very valuable for a real state agent
who could make use of the information provided on a daily basis. II. Data dictionary:
The dataset used in this project comes from the UCI Machine Learning
Repository. This data was collected in 1978 and each of the 506 entries represents
aggregate information about 13 features of homes from various suburbs located in Boston
and some data about buyer, seller and investor information is generated by us from Group 12 23/12/2023
collecting information on the internet. And here is 13 detailed attribute information can be found below: Attribute Information:
- CRIM: Per capita crime rate by town
- ZN: Proportion of residential land zoned for lots over 25,000 sq.ft.
- INDUS: Proportion of non-retail business acres per town
- CHAS: Charles River dummy variable (= 1 if tract bounds river; 0 otherwise)
- NOX: Nitric Oxide concentration (parts per 10 million)
- RM: The average number of rooms per dwelling
- AGE: Proportion of owner-occupied units built before 1940
- DIS: Weighted distances to five Boston employment centers
- RAD: Index of accessibility to radial highways
- TAX: Full-value property-tax rate per 10,000 dollars
- PTRATIO: Pupil-teacher ratio by town
- LSTAT: % lower status of the population
- MEDV: Median value of owner-occupied homes in 1000 dollars Group 12 23/12/2023
III. Analyzing and draw the ERD diagram
The entity relationship diagram can be thought of as the database's design sketch.
ERD provides visualization for database design, hence it serves the following functions:
- Supports in the definition of information system requirements across the
organization and assists users in planning how to organize data. It facilitates
planning before beginning to build the tables.
- The ERD diagram can be used as a document to help others comprehend the database's core.
- The ERD diagram depicts the database's logical structure so that users can understand it. Group 12 23/12/2023
- Once the relational database has been deployed, the ERD can still be used as a
reference point if the debug or business process needs to be re-established later.
Analyzing the entities:
+ Property: the property table includes the address, number of floors, year of
construction, area of 1 property, and the ID attached to each property.
+ Person: the person table plays the role of managing the properties, through the
propertyID and it is divided into 3 main categories (Seller, Customer, Investor)
through the ID of the table role
+ Roles: role table for information about types of people (Seller, Customer, Investor)
+ Status: status table to view the status of the property based on the ID of the
table status (sold, on sale, fixing)
+ HousePrices: house price list for sale date and original selling price of the property via propertyID
+ MarketData: provides information about the real estate market by address and
date and at each time there is a main keyword, MarketDataID
+ Prediction: provide the property's predicted date and price via the propertyID
and the MarketData table influenced prediction table via the MarketDataID
+ PropertyType: this table for found property's classification (Villa, Apartment, Cabin, Penthouse) via TypeID
+ Interior: this table shows the interior of each property based on the PropertyID. IV. Relational Schema:
The Relational Schema is generated from the ERD, displaying the table elements that
correspond to the entities and providing table designers in SQL server with a more detailed
perspective of the table implementation.
V. Build a database using SQL Sever -- Create Database
CREATE DATABASE BostonHousePricePredictionDB; GO 9 -- Use Database
USE BostonHousePricePredictionDB; GO
-- Create table Role CREATE TABLE Role (
roleID int IDENTITY(1,1) NOT NULL, roleName varchar(30) NOT NULL,
CONSTRAINT PK_Role PRIMARY KEY CLUSTERED (roleID ASC) ); GO
-- Create table Status CREATE TABLE Status (
statusID int IDENTITY(1,1) NOT NULL, statusName varchar(30) NOT NULL,
CONSTRAINT PK_Status PRIMARY KEY CLUSTERED (statusID ASC) ); GO
-- Create table PropertyType CREATE TABLE
PropertyType ( typeID int IDENTITY(1,1) NOT NULL,
typeName varchar(30) NOT NULL,
CONSTRAINT PK_PropertyType PRIMARY KEY CLUSTERED (typeID ASC) ); GO
-- Create table MarketData CREATE TABLE MarketData (
marketDataID int IDENTITY(1,1) NOT NULL, date date NOT
NULL, address varchar(100) NOT NULL, CRIM float NOT NULL, ZN float NOT NULL, INDUS float NOT NULL, CHAS bit NOT NULL, NOX float NOT NULL, RM float NOT NULL, AGE float NOT NULL, DIS float NOT NULL, RAD int NOT NULL, TAX int NOT NULL, PTRATIO float NOT NULL, LSTAT float NOT NULL, MEDV float NOT NULL,
CONSTRAINT PK_MarketData PRIMARY KEY CLUSTERED (marketDataID ASC) ); GO
-- Create table Person CREATE TABLE Person (
personID int IDENTITY(1,1) NOT NULL,
name varchar(50) NOT NULL, -- Changed to singular for consistency phone varchar(11) NOT NULL,
address varchar(100) NOT NULL, gender bit NOT NULL,
roleID int FOREIGN KEY REFERENCES Role(roleID) NOT NULL, CONSTRAINT PK_Person PRIMARY KEY CLUSTERED (personID ASC) 10 ); GO
-- Create table Property CREATE TABLE Property (
propertyID int IDENTITY(1,1) NOT NULL, squareFootage
decimal(10,4) NOT NULL, floor int NOT NULL, yearBuilt
date NOT NULL, address varchar(100) NOT NULL,
saleDate date NOT NULL, salePrice decimal(8,4) NOT NULL,
typeID int FOREIGN KEY REFERENCES PropertyType(typeID) NOT NULL, statusID int FOREIGN KEY
REFERENCES Status(statusID) NOT NULL, personID int FOREIGN KEY REFERENCES Person(personID) NOT NULL,
CONSTRAINT PK_Property PRIMARY KEY CLUSTERED (propertyID ASC) ); GO
-- Create table Interior CREATE TABLE
Interior ( propertyID int NOT NULL, numBedRooms int NOT NULL,
numBathrooms int NOT NULL, kitchen bit
NOT NULL, pool bit NOT NULL, garden
bit NOT NULL, garage bit NOT NULL,
CONSTRAINT FK_Interior_Property FOREIGN KEY (propertyID) REFERENCES Property(propertyID),
CONSTRAINT PK_Interior PRIMARY KEY CLUSTERED (propertyID ASC) ); GO
-- Create table Prediction CREATE TABLE Prediction ( propertyID
int NOT NULL, marketDataID int NOT NULL, predictionDate
date NOT NULL, predictionPrice decimal(8,3) NOT NULL,
CONSTRAINT FK_Prediction_Property FOREIGN KEY (propertyID) REFERENCES Property(propertyID),
CONSTRAINT FK_Prediction_MarketData FOREIGN KEY (marketDataID) REFERENCES MarketData(marketDataID),
CONSTRAINT PK_Prediction PRIMARY KEY CLUSTERED (propertyID, marketDataID ASC) ); GO -- Insert data
INSERT INTO Role VALUES('Seller');
INSERT INTO Role VALUES('Customer');
INSERT INTO Role VALUES('Investor');
INSERT INTO Status VALUES('On Sale');
INSERT INTO Status VALUES('Sold');
INSERT INTO Status VALUES('Fixing');
INSERT INTO PropertyType VALUES('Villa');
INSERT INTO PropertyType VALUES('Cabin');
INSERT INTO PropertyType VALUES('Apartment');
INSERT INTO PropertyType VALUES('Condo');
INSERT INTO Person VALUES('Andrew Garfield', '08172645781', '408 5th Ave, Brooklyn, United States', 0, 1);
INSERT INTO Person VALUES('Charlie Puth', '04716284625', '3548 S Jefferson St #52, Falls Church, United States', 0, 2);
INSERT INTO Person VALUES('Selena Gomez', '0751827458', '1455 S Lamb Blvd, Las Vegas, United States', 0, 3); 11
INSERT INTO Property VALUES(5000, 2, '2018-04-11', '974 Blue Hill Avenue, Boston, United States', '2023-01-09', 3012, 1, 1, 1);
INSERT INTO Property VALUES(3670, 1, '2012-06-20', '521 Washington St, Boston, United States', '2019-10-10', 5921, 2, 1, 1);
INSERT INTO Property VALUES(2830, 3, '2015-07-10', '415 American Legion Hwy, Boston, United States', '2020-01-07', 5921, 3, 2, 1);
INSERT INTO Interior VALUES(3,2,1,1,0,1);
INSERT INTO Interior VALUES(2,2,1,0,0,0);
INSERT INTO Interior VALUES(3,1,1,0,1,1);
INSERT INTO Interior VALUES(1,1,1,1,0,0);
INSERT INTO Interior VALUES(2,2,1,0,1,1);
INSERT INTO MarketData VALUES('2023-01-01', 'Blue Hill Avenue, Boston, United States',
0.00632, 18, 2.31, 0, 0.538, 6.575, 65.2, 4.09, 1,296, 15.3, 4.98, 24);
INSERT INTO MarketData VALUES('2023-03-01', 'Blue Hill Avenue, Boston, United States',
0.02731, 0, 7.07, 0, 0.469, 6.421, 78.9, 4.9671, 2,242, 17.8, 9.14, 21.6);
INSERT INTO MarketData VALUES('2023-06-01', 'Blue Hill Avenue, Boston, United States',
0.02729, 0, 7.07, 0, 0.469, 7.185, 61.1, 4.9671, 2,242, 17.8, 4.03, 34.7);
INSERT INTO Prediction VALUES(1,1,'2023-01-01', 9992.213);
INSERT INTO Prediction VALUES(1,2,'2023-03-01', 10000.324); INSERT INTO Prediction
VALUES(1,3,'2023-06-01', 8823.534); Business Questions:
1.Display all houses in Boston ? SELECT * FROM Property Output:
2. Print out the houses with the smallest principal amount? SELECT * FROM Property
WHERE salePrice = (SELECT MIN(salePrice) FROM Property) Output: 12
3. Print out houses located in the Adams ? SELECT * FROM Property
WHERE Property.address like '%' + 'Adams' + '%' Output:
4. Find and print the homes with the lowest principal on Blue Hill Avenue ? SELECT * FROM Property
WHERE Property.address like '%'+'Blue Hill Avenue'+'%' ORDER BY
Property.salePrice Output:
5. Find 10 homes with the lowest predicted price in June 2023? SELECT TOP 10 * FROM Property
INNER JOIN Prediction ON Property.propertyID = Prediction.propertyID
WHERE MONTH(predictionDate) = 6 ORDER BY predictionPrice Output:
6. Find the 10 homes with the lowest predicted prices between September and December 2023? SELECT * FROM Property
INNER JOIN Prediction ON Property.propertyID = Prediction.propertyID 13
WHERE MONTH(predictionDate) BETWEEN 9 AND 12 ORDER BY
predictionPrice Output:
7. Find homes by status?
CREATE PROCEDURE PropertyStatus @statusName nvarchar(30) AS SELECT * FROM Property
INNER JOIN Status ON Property.statusID = Status.statusID WHERE Status.statusName = @statusName EXEC
PropertyStatus @statusName = 'On Sale' Output:
8. Print out the predicted prices of homes currently for sale in September? SELECT * FROM Property
INNER JOIN Status ON Status.statusID = Property.statusID
INNER JOIN Prediction ON Prediction.propertyID = Property.propertyID WHERE Status.statusID
= 1 AND MONTH(Prediction.predictionDate) = 9 14 Output:
9. Print owners of more than 2 property?
SELECT Person.name AS Name, COUNT(propertyID) AS
NumberOfProperties FROM (Property
INNER JOIN Person ON Property.personID = Person.personID) GROUP BY name
HAVING COUNT(propertyID) > 2; Output:
10.Use trigger-tran to suppress unwanted inserts? CREATE TRIGGER CheckInsert ON Person FOR INSERT, UPDATE AS BEGIN ROLLBACK TRAN
Print('CHECK INSERT CAREFULLY!!!') END GO
INSERT INTO Person VALUES('Melody Mark', '08172645723', '408 Adams St, Brooklyn, United States', 1, 2); Output: 15 VI. Conclusion:
The task of this database system is to help the store data and information in a
consistent manner, avoiding redundancy in each specific category. By building a
database system, customers can easily look up house prices in Boston (quantity, condition, ...).
In I, we summarize the importance of housing and the housing market impacts
in relation to these important factors. In II, we generate Boston housing data to bring
them into the ERD diagram in III. From ERD we created Relational Schema and then
used SQL statement to build database by using SQL Sever. Finally made up 10
questions which can be answered by retrieving in the information from the database. VII. Reference
Boston house price prediction | Kaggle
Boston House Price Prediction Using Machine Learning
Machine Learning Project: Predicting Boston House Prices With Regression | by
Victor Roman | Towards Data Science
Machine_Leaning_Engineer_Udacity_NanoDegree/projects/boston_housing at master
· rromanss23/Machine_Leaning_Engineer_Udacity_NanoDegree · GitHub
Boston Home Prices Prediction and Evaluation | Machine Learning , Deep Learning, and Computer Vision
Boston Housing - Price Prediction 16