200 likes | 318 Vues
TenMan Systems, a leading real estate investment trust, manages extensive commercial properties. This overview outlines essential database applications for lease payments, tenant management, and accounts receivable. Key functionalities include precise calculations of monthly lease payments, tenant billing, overdue account management, and detailed tenant information management. The system leverages SQL queries for tracking lease expirations, current percentage rent charges, and unpaid charges. Understanding the complexities of database design and maintenance is crucial for effective property management.
E N D
Database Applications Cynthia Marsh Gwen Marlor Byron McCluney
TenMan Systems, Inc. • TenMan operates a larger real estate investment trust that owns thousands of commercial properties. • TenMan’s computer system needs include: • The calculated monthly lease payments • Billing the tenants • Posting the cash received • Managing overdue accounts
Lease Payments • The information needed from a tenant includes the following: • Tenant Name, Address, Phone Number, Contact Information, Lease Start Date, Lease End Date. • A lease always starts at the beginning of a month and ends at the end of the month.
Type Costs • Along with the monthly rent the tenant will be charged for the following: • (R, Rent) • (I, Insurance) • (T, Property Tax) • (P, Percentage Rent)-Calculated Annually • Charged Monthly • ((AnnualSales – BaseSales)*PercentageRate)/12
DBDL for Ten-Man Systems Tenant(TenantNum, Name, Street, City, State, Zip, Phone, ContactPerson, LeaseStart, LeaseEnd, BaseSales, PercentRate)
DBDL for Ten-Man Systems CostType(Type, Description) RentCosts(RentCostNum, TenantNum, Type, Amount, StartDate, EndDate) FK TenantNum -> Tenant FK Type -> CostType
DBDL for Ten-Man Systems AR(ARNum, InvoiceNum, Type, TenantNum, Date, Amount) FK TenantNum -> Tenant FK Type -> CostType
DBDL for Ten-Man Systems ARHistory(ARNum, InvoiceNum, Type, TenantNum, Date, Amount) FK TenantNum -> Tenant FK Type -> CostType TenantSales(TenantNum, Date, Amount) FK TenantNum -> Tenant
Monthly Events (Queries) A query that shows lease that will expire within the next 12 months: • SELECT * • FROM Tenant • WHERE LeaseEnd < '2005-03-31' + INTERVAL 12 MONTH; or • SELECT * • FROM Tenant • WHERE LeaseEnd < DATE_SUB(CURDATE(),INTERVAL 12 MONTH);
Monthly Events (Queries) A query that shows the current percentage rent charges, with the largest charges first: • SELECT * • FROM AccountsReceivable • WHERE Type = 'P' • AND MONTH(ARDate) = 02 • AND YEAR(ARDate) = 2005 • ORDER BY Amount DESC; or • SELECT * • FROM AccountsReceivable • WHERE Type = 'P' • AND YEAR(ARDate) = YEAR(CURDATE()) • AND MONTH(ARDate) = MONTH(CURDATE()) • ORDER BY Amount DESC;
Monthly Events (Queries) A query that shows all charges unpaid during the current month: • SELECT AccountsReceivable.TenantNum, TName, SUM(Amount) • FROM AccountsReceivable, Tenant • WHERE AccountsReceivable.TenantNum = Tenant.TenantNum • AND YEAR(ARDate) = 2004 • AND MONTH(ARDate) = 12 • GROUP BY AccountsReceivable.TenantNum • HAVING SUM(Amount) > 0;
Monthly Events (Queries) A query that shows all charges unpaid during the current month: Or you can: • SELECT AccountsReceivable.TenantNum, TName, SUM(Amount) • FROM AccountsReceivable, Tenant • WHERE AccountsReceivable.TenantNum = Tenant.TenantNum • AND YEAR(ARDate) = YEAR(CURDATE()) • AND MONTH(ARDate) = MONTH(CURDATE()) • GROUP BY AccountsReceivable.TenantNum • HAVING SUM(Amount) > 0;
Monthly Events (Queries) A query that shows all charges unpaid during all previous months. The oldest will appear first: • SELECT AccountsReceivable.TenantNum, TName, SUM(Amount) • FROM AccountsReceivable, Tenant • WHERE AccountsReceivable.TenantNum = Tenant.TenantNum • AND ARDate < '2005-03-31' • GROUP BY AccountsReceivable.TenantNum • HAVING SUM(Amount) > 0 • ORDER BY Amount DESC;
Monthly Events (Queries) A query that shows all charges unpaid during all previous months. The oldest will appear first: or • SELECT AccountsReceivable.TenantNum, TName, SUM(Amount) • FROM AccountsReceivable, Tenant • WHERE AccountsReceivable.TenantNum = Tenant.TenantNum • AND ARDate < CURDATE() • GROUP BY AccountsReceivable.TenantNum • HAVING SUM(Amount) > 0 • ORDER BY Amount DESC;
Monthly Events (Queries) A query that displays the accounts receivable history showing the number of days taken to pay an individual charge. This query will be ordered with the greatest number of days first: CREATE TEMPORARY TABLE tempDays1 SELECT TenantNum, Min(ARDate) AS minDate FROM ARHistory GROUP BY TenantNum, InvoiceNum; CREATE TEMPORARY TABLE tempDays2 SELECT TenantNum, MAX(ARDate) AS maxDate FROM ARHistory GROUP BY TenantNum, InvoiceNum; SELECT tempDays1.TenantNum, DATEDIFF(tempDays2.maxDate, tempDays1.minDate) AS NumberOfDays FROM tempDays1, tempDays2 WHERE tempDays1.TenantNum = tempDays2.TenantNum GROUP BY tempDays1.TenantNum;
Summary • What Did We Learn? • Filling a database with data can be a complex difficult process • Developing a good plan is important • Find Tables • DBDL and ER Diagrams • Make a Script to Create and to Drop Tables
Summary Continued • What Did We Learn? • Prepare yourself for hours of debugging • Small things are easy to miss at first • Test a piece at a time • Queries can be more challenging than they appear at first • Work it out on paper or white board • Know what the results should look like • Test until query produces desired output