-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_database.sql
74 lines (72 loc) · 1.8 KB
/
setup_database.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
USE HousingDataCleaning;
DROP TABLE NashvilleHousing;
CREATE TABLE NashvilleHousing (
UniqueID INT,
ParcelID VARCHAR(100),
LandUse VARCHAR(100),
PropertyAddress VARCHAR(100),
SaleDate VARCHAR(100),
SalePrice INT,
LegalReference VARCHAR(100),
SoldAsVacant VARCHAR(100),
OwnerName VARCHAR(100),
OwnerAddress VARCHAR(100),
Acreage FLOAT,
TaxDistrict VARCHAR(100),
LandValue INT,
BuildingValue INT,
TotalValue INT,
YearBuilt INT,
Bedrooms INT,
FullBath INT,
HalfBath INT
);
-- Data Import for NashvilleHousing
LOAD DATA LOCAL INFILE '/path/to/your/Nashville Housing Data for Data Cleaning.csv'
INTO TABLE NashvilleHousing
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS
(
UniqueID,
ParcelID,
LandUse,
PropertyAddress,
SaleDate,
SalePrice,
LegalReference,
SoldAsVacant,
OwnerName,
OwnerAddress,
Acreage,
TaxDistrict,
LandValue,
BuildingValue,
TotalValue,
YearBuilt,
Bedrooms,
FullBath,
HalfBath
)
SET
UniqueID = NULLIF(UniqueID, ''),
ParcelID = NULLIF(ParcelID, ''),
LandUse = NULLIF(LandUse, ''),
PropertyAddress = NULLIF(PropertyAddress, ''),
SaleDate = NULLIF(SaleDate, ''),
SalePrice = NULLIF(SalePrice, ''),
LegalReference = NULLIF(LegalReference, ''),
SoldAsVacant = NULLIF(SoldAsVacant, ''),
OwnerName = NULLIF(OwnerName, ''),
OwnerAddress = NULLIF(OwnerAddress, ''),
Acreage = NULLIF(Acreage, ''),
TaxDistrict = NULLIF(TaxDistrict, ''),
LandValue = NULLIF(LandValue, ''),
BuildingValue = NULLIF(BuildingValue, ''),
TotalValue = NULLIF(TotalValue, ''),
YearBuilt = NULLIF(YearBuilt, ''),
Bedrooms = NULLIF(Bedrooms, ''),
FullBath = NULLIF(FullBath, ''),
HalfBath = NULLIF(HalfBath, '')
;