-- Lambda Properties Management 1 --

USE master
GO
CREATE DATABASE LPM1; -- Stands for Lambda Properties Management 1;
GO

USE LPM1;
GO
CREATE SCHEMA Management;
GO
CREATE SCHEMA Presentation;
GO
CREATE SCHEMA Rentals;
GO
CREATE SCHEMA Listing;
GO

CREATE TABLE Rentals.OccupanciesStatus
(
	OccupancyStatus	  nvarchar(20) not null,
	StatusDescription nvarchar(max),
	Constraint PK_OccupanciesStatus Primary Key(OccupancyStatus)
);
GO
CREATE TABLE Rentals.PropertiesTypes
(
	PropertyType	nvarchar(20) not null,
	TypeDescription nvarchar(max),
	Constraint PK_PropertiesTypes Primary Key(PropertyType)
);
GO
CREATE TABLE Presentation.Units
(
	[Address]      nvarchar(50),
	UnitNumber     nchar(10),
	City           nvarchar(40),
	[State]        nvarchar(40),
	ZIPCode        nvarchar(10),
	Bedrooms       int,
	Bathrooms      real,
	Price          money,
	Deposit        money,
	Available      bit
);
GO
CREATE TABLE Listing.AlexandriaApartments
(
	ApartmentCode   nvarchar(10),
	[Address]   	nvarchar(50),
	ApartNbr        nvarchar(6),
	City	        nvarchar(40),
	[State] 	nvarchar(40),
	ZIP	        nvarchar(20),
	Bedrooms    	smallint,
	Bathrooms   	float,
	MonthRent       money,
	InitialDeposit	money
);
GO
CREATE TABLE Listing.HousesUnderOurManagement
(
	HouseNbr        nvarchar(10),
	HouseCategory   nvarchar(20),
	[Address]   	nvarchar(50),
	City	        nvarchar(40),
	[State] 	nvarchar(40),
	ZIPCode         nvarchar(20),
	Beds    	smallint,
	Baths   	float,
	RentAmount      money,
	Deposit		money,
	[Availability]	nvarchar(20)
);
GO
CREATE TABLE Listing.Condominiums
(
	CondoCode       nvarchar(10),
	[Address]   	nvarchar(50),
	CondoNbr        nvarchar(6),
	City	        nvarchar(40),
	[State] 	nvarchar(40),
	PostalCode      nvarchar(20),
	Beds    	smallint,
	Baths   	float,
	Rent            money,
	SecDepot	money,
	[Status]	nvarchar(20)
);
GO
CREATE TABLE Listing.Properties
(
	PropertyNumber  nvarchar(10),
	PropertyType    nvarchar(20),
	[Address]   	nvarchar(50),
	UnitNumber      nvarchar(6),
	City	        nvarchar(40),
	[State]	        nvarchar(40),
	ZIPCode	        nvarchar(20),
	Bedrooms    	smallint,
	Bathrooms   	float,
	MonthlyRate     money,
	SecurityDeposit	money,
	OccupancyStatus	nvarchar(20)
);
GO

INSERT INTO Rentals.OccupanciesStatus(OccupancyStatus, StatusDescription)
VALUES(N'Available', N'The apartment is ready for rent. It has passed internal and external inspections.'),
      (N'Occupied', N'The apartment is currently used by another tenant and it is not available'),
      (N'Not Ready', N'For any reason, the apartment cannot be occupied at this time. It could be due to need repair or a failed inspection.'),
      (N'Needs Repair', N'The property cannot be rented at this time because work is needed in it.'),
      (N'Other', N'The status of this property is not clearly determined.');
GO
INSERT INTO Rentals.PropertiesTypes(PropertyType, TypeDescription)
VALUES(N'Apartment', N'An apartment is a property located in a building made of one or more (2, 3, 5, 6, 10, 20, or even more) levels. The whole building is made of apartments and units used for management.'),
      (N'Condominium', N'A condominium (also called a condo) primarily follows the description of an apartment. The small difference is that, in most cases, only one company manages all the apartments in the building. In the case of a condo, different independent companies may be in charge of different units. Some other condos in the same building be occupied by people who are currently purchasing, as opposed to renting, them.'),
      (N'Townhouse', N'A townhouse is a house that is attached to at least one other house. In most cases, townhouse has 1, 2, or 3 levels (not more, based on the construction). In some cases, a townhouse may be built under or above another townhouse.'),
      (N'Single Family', N'A single family is a house that stands by itself and is occupied by one or more people who live as family members or acquaintances.'),
      (N'Other', N'The property fits none of the other descriptions');
GO
INSERT Presentation.Units
VALUES(N'6802 Gulf Branch Ave', N'101', N'Rockville', N'MD', N'20850', 0, 1.00, 845.00,  200.00, 0),
      (N'6802 Gulf Branch Ave', N'102', N'Rockville', N'MD', N'20850', 1, 1.00, 895.00,  250.00, 0),
      (N'6802 Gulf Branch Ave', N'103', N'Rockville', N'MD', N'20850', 1, 1.00, 925.00,  275.00, 1),
      (N'6802 Gulf Branch Ave', N'104', N'Rockville', N'MD', N'20850', 2, 1.00, 1050.00, 300.00, 0),
      (N'6802 Gulf Branch Ave', N'105', N'Rockville', N'MD', N'20850', 1, 1.00, 885.00,  250.00, 1),
      (N'6802 Gulf Branch Ave', N'106', N'Rockville', N'MD', N'20850', 3, 2.00, 1350.00, 425.00, 1),
      (N'6802 Gulf Branch Ave', N'107', N'Rockville', N'MD', N'20850', 2, 2.00, 1185.00, 400.00, 0),
      (N'6802 Gulf Branch Ave', N'108', N'Rockville', N'MD', N'20850', 0, 1.00, 865.00,  225.00, 1),
      (N'6802 Gulf Branch Ave', N'109', N'Rockville', N'MD', N'20850', 2, 1.00, 1050.00, 350.00, 1),
      (N'6802 Gulf Branch Ave', N'110', N'Rockville', N'MD', N'20850', 1, 1.00, 895.00,  250.00, 0),
      (N'6802 Gulf Branch Ave', N'111', N'Rockville', N'MD', N'20850', 1, 1.00, 895.00,  250.00, 0),
      (N'6802 Gulf Branch Ave', N'112', N'Rockville', N'MD', N'20850', 0, 1.00, 805.00,  200.00, 1),
      (N'6802 Gulf Branch Ave', N'201', N'Rockville', N'MD', N'20850', 0, 1.00, 825.00,  200.00, 1),
      (N'6802 Gulf Branch Ave', N'202', N'Rockville', N'MD', N'20850', 1, 1.00, 950.00,  325.00, 0),
      (N'6802 Gulf Branch Ave', N'203', N'Rockville', N'MD', N'20850', 1, 1.00, 885.00,  250.00, 1),
      (N'6802 Gulf Branch Ave', N'204', N'Rockville', N'MD', N'20850', 2, 2.00, 1125.00, 425.00, 1),
      (N'6802 Gulf Branch Ave', N'205', N'Rockville', N'MD', N'20850', 1, 1.00, 1055.00, 350.00, 0),
      (N'6802 Gulf Branch Ave', N'206', N'Rockville', N'MD', N'20850', 2, 1.00, 1165.00, 400.00, 1),
      (N'6802 Gulf Branch Ave', N'207', N'Rockville', N'MD', N'20850', 1, 1.00, 895.00,  250.00, 0),
      (N'6802 Gulf Branch Ave', N'208', N'Rockville', N'MD', N'20850', 0, 1.00, 815.00,  200.00, 1),
      (N'6802 Gulf Branch Ave', N'210', N'Rockville', N'MD', N'20850', 1, 1.00, 895.00,  350.00, 1),
      (N'6802 Gulf Branch Ave', N'211', N'Rockville', N'MD', N'20850', 2, 2.00, 925.00,  400.00, 1),
      (N'6802 Gulf Branch Ave', N'212', N'Rockville', N'MD', N'20850', 3, 2.00, 1280.00, 500.00, 0),
      (N'6802 Gulf Branch Ave', N'301', N'Rockville', N'MD', N'20850', 0, 1.00, 845.00,  200.00, 0),
      (N'6802 Gulf Branch Ave', N'302', N'Rockville', N'MD', N'20850', 1, 1.00, 925.00,  250.00, 0),
      (N'6802 Gulf Branch Ave', N'303', N'Rockville', N'MD', N'20850', 2, 1.00, 985.00,  275.00, 1),
      (N'6802 Gulf Branch Ave', N'304', N'Rockville', N'MD', N'20850', 2, 2.00, 1250.00, 300.00, 0),
      (N'6802 Gulf Branch Ave', N'305', N'Rockville', N'MD', N'20850', 1, 1.00, 945.00,  250.00, 1),
      (N'6802 Gulf Branch Ave', N'306', N'Rockville', N'MD', N'20850', 3, 2.00, 1350.00, 425.00, 1),
      (N'6802 Gulf Branch Ave', N'307', N'Rockville', N'MD', N'20850', 2, 2.00, 1285.00, 400.00, 0),
      (N'6802 Gulf Branch Ave', N'308', N'Rockville', N'MD', N'20850', 0, 1.00, 875.00,  225.00, 1),
      (N'6802 Gulf Branch Ave', N'309', N'Rockville', N'MD', N'20850', 2, 1.00, 1150.00, 350.00, 1),
      (N'6802 Gulf Branch Ave', N'310', N'Rockville', N'MD', N'20850', 1, 1.00, 955.00,  250.00, 0),
      (N'6802 Gulf Branch Ave', N'311', N'Rockville', N'MD', N'20850', 3, 2.00, 1325.00, 500.00, 0),
      (N'6802 Gulf Branch Ave', N'312', N'Rockville', N'MD', N'20850', 0, 1.00, 825.00,  200.00, 1);
GO

INSERT INTO Listing.AlexandriaApartments(ApartmentCode, [Address], ApartNbr, City,
	[State], ZIP, Bedrooms, Bathrooms, MonthRent, InitialDeposit)
VALUES(N'620048', N'10314 Springster Rd #1A', N'1A', N'Alexandria', N'VA', N'22312', 1, 1, 1150,  800),
      (N'294859', N'10314 Springster Rd #1B', N'1B', N'Alexandria', N'VA', N'22312', 2, 1, 1375, 1000),
      (N'620485', N'10314 Springster Rd #1C', N'1C', N'Alexandria', N'VA', N'22312', 2, 2, 1425, 1200),
      (N'175947', N'10314 Springster Rd #1D', N'1D', N'Alexandria', N'VA', N'22312', 3, 2, 1650, 1400),
      (N'597030', N'10314 Springster Rd #2A', N'2A', N'Alexandria', N'VA', N'22312', 1, 1, 1150,  800),
      (N'682048', N'10314 Springster Rd #2B', N'2B', N'Alexandria', N'VA', N'22312', 2, 1, 1375, 1000),
      (N'927394', N'10314 Springster Rd #2C', N'2C', N'Alexandria', N'VA', N'22312', 2, 2, 1425, 1200),
      (N'350511', N'10314 Springster Rd #2D', N'2D', N'Alexandria', N'VA', N'22312', 3, 2, 1650, 1400),
      (N'628048', N'10314 Springster Rd #3A', N'3A', N'Alexandria', N'VA', N'22312', 1, 1, 1150,  800),
      (N'970530', N'10314 Springster Rd #3B', N'3B', N'Alexandria', N'VA', N'22312', 2, 1, 1375, 1000),
      (N'297297', N'10314 Springster Rd #3C', N'3C', N'Alexandria', N'VA', N'22312', 2, 2, 1425, 1200),
      (N'495596', N'10314 Springster Rd #3D', N'3D', N'Alexandria', N'VA', N'22312', 3, 2, 1650, 1400),
      (N'304060', N'10316 Springster Rd #1A', N'1A', N'Alexandria', N'VA', N'22312', 1, 1, 1250, 1000),
      (N'396922', N'10316 Springster Rd #1B', N'1B', N'Alexandria', N'VA', N'22312', 2, 1, 1450, 1200),
      (N'795007', N'10316 Springster Rd #1C', N'1C', N'Alexandria', N'VA', N'22312', 2, 2, 1600, 1400),
      (N'600406', N'10316 Springster Rd #1D', N'1D', N'Alexandria', N'VA', N'22312', 2, 1, 1500, 1200),
      (N'409496', N'10316 Springster Rd #2A', N'2A', N'Alexandria', N'VA', N'22312', 1, 1, 1250, 1000),
      (N'639496', N'10316 Springster Rd #2B', N'2B', N'Alexandria', N'VA', N'22312', 2, 1, 1450, 1200),
      (N'394060', N'10316 Springster Rd #2C', N'2C', N'Alexandria', N'VA', N'22312', 2, 2, 1600, 1400),
      (N'602408', N'10316 Springster Rd #2D', N'2D', N'Alexandria', N'VA', N'22312', 2, 1, 1500, 1200),
      (N'628408', N'10316 Springster Rd #3A', N'3A', N'Alexandria', N'VA', N'22312', 1, 1, 1250, 1000),
      (N'409362', N'10316 Springster Rd #3B', N'3B', N'Alexandria', N'VA', N'22312', 1, 1, 1450, 1200),
      (N'926836', N'10316 Springster Rd #3C', N'3C', N'Alexandria', N'VA', N'22312', 2, 2, 1600, 1400),
      (N'630496', N'10316 Springster Rd #3D', N'3D', N'Alexandria', N'VA', N'22312', 2, 1, 1500, 1000);
GO

INSERT INTO Listing.HousesUnderOurManagement(HouseNbr, HouseCategory, [Address], City, [State],
			ZIPCode, Beds, Baths, RentAmount, Deposit, [Availability])
VALUES(N'884804', N'Single Family', N'8602 Jorham Drv',        N'Silver Spring',     N'MD', N'20906', 5, 3.5, 2880, 1000, N'Available'),
      (N'204058', N'Single Family', N'426 Zimmers Rd',         N'Silver Spring',     N'MD', N'20901', 4, 2.5, 2650, 1000, N'Available'),
      (N'844850', N'Townhouse',     N'688 Larrington St NW',   N'Washington',        N'DC', N'20012', 3, 2.5, 1450, 850, N'Available'),
      (N'280495', N'Single Family', N'12304 Donaldson Rd',     N'College Park',      N'MD', N'20740', 4, 3.5, 2500, 1000, N'Not Ready'),
      (N'632409', N'Single Family', N'7002 War Fair Drv',      N'Arlington',         N'VA', N'22201', 5, 3.5, 3200, 1500, N'Available'),
      (N'928028', N'Townhouse',     N'2410 Jerridan Str NW',   N'Washington',        N'DC', N'20008', 4, 3.5, 2850, 1250, N'Available'),
      (N'248664', N'Townhouse',     N'10344 Dunfield Drv',     N'Columbia',          N'MD', N'21045', 3, 2.5, 1850, 1200, N'Available'),
      (N'828479', N'Single Family', N'9910 East Rolling Rd',   N'Silver Spring',     N'MD', N'20910', 4, 3.5, 2485, 1200, N'Available'),
      (N'592739', N'Townhouse',     N'8114 Parlance Rd',       N'Silver Spring',     N'MD', N'20902', 3, 2.5, 1580, 1250, N'Needs Repair'),
      (N'188483', N'Townhouse',     N'1406 Great Rossy Ave',   N'Columbia',          N'MD', N'21045', 3, 2.5, 1665, 1200, N'Available'),
      (N'182839', N'Townhouse',     N'10708 Silver Stone Str', N'Arlington', N'VA', N'22201', 3, 2.5, 1885, 1200, N'Available'),
      (N'929375', N'Single Family', N'1505 Leamington Rd',     N'College Park', N'MD', N'20740', 5, 2.5, 2600, 1500, N'Needs Repair'),
      (N'496055', N'Townhouse',     N'6812 Jerry Woods Ave',   N'Silver Spring', N'MD', N'20906', 3, 2.5, 1580, 1200, N'Available'),
      (N'400486', N'Townhouse',     N'1408 Great Rossy Ave',   N'Columbia', N'MD', N'21045', 4, 2.5, 1200, 800, N'Available'),
      (N'205840', N'Single Family', N'929 Carnage Crt',        N'Gaithersburg', N'MD', N'20877', 3, 2.5, 1500, 1200, N'Available'),
      (N'240051', N'Townhouse',     N'1877 Charley Rd',        N'Arlington', N'VA', N'22202', 3, 1.5, 1575, 1200, N'Available'),
      (N'726385', N'Single Family', N'664 Vast Armey Way',     N'Alexandria', N'VA', N'22312', 4, 3.5, 2425, 1500, N'Not Ready'),
      (N'602408', N'Townhouse',     N'1410 Great Rossy Ave',   N'Columbia', N'MD', N'21045', 4, 2.5, 2475, 1500, N'Available'),
      (N'729384', N'Single Family', N'2214 East Jonathan Crt', N'Silver Spring', N'MD', N'20901', 3, 1.5, 1575, 1200, N'Available'),
      (N'620494', N'Single Family', N'8288 Prophesia Way',     N'Annapolis', N'MD', N'20404', 4, 2.5, 1250, 1000, N'Needs Repair'),
      (N'724085', N'Townhouse',     N'2505 Renaissance Ln',    N'Silver Spring', N'MD', N'20904', 3, 2.5, 1885, 1200, N'Available'),
      (N'396922', N'Single Family', N'7114 West Janitor Str',  N'Rockville', N'MD', N'20854', 4, 2.5, 2650, 1500, N'Available'),
      (N'380685', N'Single Family', N'375 Reisters Way',       N'Arlington', N'VA', N'22203', 5, 2.5, 3250, 1500, N'Needs Repair'),
      (N'592739', N'Townhouse',     N'10224 Pleasntry Ave',    N'College Park', N'MD', N'20740', 3, 2.5, 1450, 1000, N'Available'),
      (N'926836', N'Single Family', N'681 Jane Mood St',       N'Alexandria', N'VA', N'22312', 3, 2.5, 1890, 1200, N'Available'),
      (N'939475', N'Townhouse',     N'1044 Connors Rd NW',     N'Washington', N'DC', N'20004', 4, 2.5, 1775, 1200, N'Available'),
      (N'929475', N'Single Family', N'206 Checker Ct',         N'Silver Spring', N'MD', N'20901', 5, 3.5, 2750, 1500, N'Not Ready'),
      (N'284957', N'Single Family', N'8249 North Plum Ave',    N'Bethesda',      N'MD', N'20814', 4, 3.5, 2880, 1500, N'Available'),
      (N'929475', N'Townhouse',     N'1412 Great Rossy Ave',   N'Columbia',      N'MD', N'21045', 3, 1.5, 1750, 1200, N'Available'),
      (N'952948', N'Single Family', N'771 Glentley Rd',        N'Alexandria',    N'VA', N'22312', 3, 2, 2200, 1400, N'Needs Repair'),
      (N'939595', N'Townhouse',     N'1844 Willow Woodson Rd', N'Rockville',     N'MD', N'20854', 3, 1.5, 1885, 1200, N'Available');
GO

INSERT INTO Listing.Condominiums(CondoCode, [Address], CondoNbr, City, [State], PostalCode, Beds, Baths, Rent, SecDepot, [Status])
VALUES(N'602950', N'3139 Orchard Ridge Ave', N'B4',   N'Baltimore', N'MD', N'21201', 1, 1,  820,  500, N'Available'),
      (N'927497', N'4606 Canterbury Ave',    N'606',  N'Bethesda',  N'MD', N'20814', 2, 2, 1475, 1000, N'Available'),
      (N'293848', N'4606 Canterbury Ave',    N'605',  N'Bethesda',  N'MD', N'20814', 1, 1, 1265,  850, N'Available'),
      (N'620952', N'4606 Canterbury Ave',    N'802',  N'Bethesda',  N'MD', N'20814', 1, 1, 1265,  850, N'Available'),
      (N'729384', N'4606 Canterbury Ave',    N'804',  N'Bethesda',  N'MD', N'20814', 2, 2, 1475, 1000, N'Available'),
      (N'939595', N'3139 Orchard Ridge Ave', N'E2',   N'Baltimore', N'MD', N'21201', 1, 1,  760,  500, N'Available'),
      (N'409496', N'4606 Canterbury Ave',    N'1012', N'Bethesda',  N'MD', N'20814', 1, 1, 1265,  850, N'Available'),
      (N'682846', N'3139 Orchard Ridge Ave', N'B1',   N'Baltimore', N'MD', N'21201', 3, 2, 1480, 1000, N'Available'),
      (N'628085', N'3139 Orchard Ridge Ave', N'W4',   N'Baltimore', N'MD', N'21201', 1, 1,  740,  500, N'Not Ready'),
      (N'597030', N'4606 Canterbury Ave',    N'1011', N'Bethesda',  N'MD', N'20814', 2, 2, 1475, 1000, N'Available'),
      (N'947085', N'4606 Canterbury Ave',    N'808',  N'Bethesda',  N'MD', N'20814', 2, 2, 1475, 1000, N'Available'),
      (N'204860', N'3139 Orchard Ridge Ave', N'D2',   N'Baltimore', N'MD', N'21201', 1, 1,  760,  500, N'Available'),
      (N'294859', N'4606 Canterbury Ave',    N'1014', N'Bethesda',  N'MD', N'20814', 1, 1, 1265,  850, N'Available'),
      (N'188483', N'3139 Orchard Ridge Ave', N'E6',   N'Baltimore', N'MD', N'21201', 2, 2, 1150,  800, N'Available'),
      (N'406802', N'3139 Orchard Ridge Ave', N'E4',   N'Baltimore', N'MD', N'21201', 3, 2, 1480, 1000, N'Available'),
      (N'704860', N'4606 Canterbury Ave',    N'1015', N'Bethesda',  N'MD', N'20814', 1, 1, 1265,  850, N'Available');
GO