Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this assignment is to give you practical experience with a relational database management system, namely the well-known and popular MySQL. In this

The purpose of this assignment is to give you practical experience with a relational database management system, namely the well-known and popular MySQL. In this assignment you are given a database schema, including a set of integrity constraints, and asked to implement and use this schema in the MySQL RDMS. Given that an empty database has been created, this entails creating the necessary tables, initializing them with some test data, and executing a variety of queries. You are also asked to draw the associated ER model. This admittedly is doing things a bit in reverse, since the normal procedure is to create the ER model first, and then use this to produce the database schema. A problem with this is that there is more than one way to do the latter, and we want to be sure that all students work with the same schema.

Problem Context

A real estate multiple listing service (MLS) keeps track of the houses and business properties for sale, the real estate agents that posts the listing to the database, and the potential buyers that are working with the agents. Houses and business properties are kinds of property. A listing entry shows information about the house or business property and the agent that posted the listing. Each agent works for a real estate firm. Buyers who are looking for houses or business properties work with a real estate agent who has access to the MLS. Following is an analysis of the information requirements and integrity constraints. Information Requirements 1) Property: Has an address, owners name, and price. 2) House: Has the information required by a property plus number of bedrooms, number of bathrooms, and size in square feet. 3) Business Property: Has information required by a property plus the type of business, e.g., gas station, store front, office space, etc., and the size in square feet. 4) Agent: Has an id, a name and phone number. An agents employment record contains the date when his/her employment started. 5) Firm: Has an id, a name, and an address. 6) Buyer: Has an id, a name, a phone number, and a set of preferences consisting of the type of property in which the buyer is interested (house or business property) and, if a house, the desired number of bedrooms and bathrooms, and, if a business, the desired type of business property, and, for either a house or business property, the desired price range. 7) Listing: Has an MLS number, the property address, the agents id, and the date the listing was posted. The MLS number serves as an id.

Database Schema

Property ( address: VARCHAR(50), ownerName: VARCHAR(30), price INTEGER ) House ( bedrooms: INTEGER, bathrooms: INTEGER, size INTEGER ) In addition, House inherits the attributes of Property, i.e., these need to be included in the House schema. BusinessProperty ( type: CHAR(20), size: INTEGER) In addition, BusinessProperty inherits the attributes of Property, i.e., these need to be included in the BusinessProperty schema. Firm ( id: INTEGER, name: VARCHAR(30), address VARCHAR(50) ) Agent ( agentId: INTEGER, name VARCHAR(30), phone CHAR(12), firmId INTEGER, dateStarted DATE ) Listings ( address: VARCHAR(50), agentId: INTEGER, mlsNumber: INTEGER, dateListed DATE) Buyer ( id: INTEGER, name VARCHAR(30), phone CHAR(12), propertyType: CHAR(20), bedrooms INTEGER, bathrooms INTEGER, businessPropertyType: CHAR(20) ), minimumPreferredPrice: INTEGER, maximumPreferredPrice: INTEGER ) Works_With( buyerId: INTEGER, agentID:INTEGER )

Integrity Constraints

1) A property is identified by its address. 2) A property can be listed by at most one agent. 3) No two listings can have the same MLS number. 4) An agent works for one, and only one, firm.

Data requirements

1) Insert sufficiently many records into your tables to return at least 1 record for each of the queries below. 2) In any case, insert at least 5 records into each table. 3) Indicate the primary keys, foreign keys, and any non-null fields appropriately.

You are to turn in:

1) An ER diagram which translates into this schema. 2) A MySQL script file that creates the tables that implement the given relation schemas and populates these tables with test data according to the instructions given above. 3) A MySQL script file containing SQL instructions that implement the queries described below. 4) A document showing the output resulting from each of the ten queries shown below.

The queries are:

1) Find the addresses of all houses currently listed. 2) Find the addresses and MLS numbers of all houses currently listed. 3) Find the addresses of all 3-becroom, 2-bathroom houses currently listed. 4) Find the addresses and prices of all 3-bedroom, 2-bathroom houses with prices in the range $100,000 to $250,000, with the results shown in descending order of price. 5) Find the addresses and prices of all business properties that are advertised as office space in descending order of price. 6) Find all the ids, names and phones of all agents, together with the names of their firms and the dates when they started. 7) Find all the properties currently listed by agent with id 001 (or some other suitable id). 8) Find all Agent.name-Buyer.name pairs where the buyer works with the agent, sorted alphabetically by Agent.name. 9) For each agent, find the total number of buyers currently working with that agent, i.e., the output should be Agent.id-count pairs. 10) For some buyer that is interested in a house, where the buyer is identified by an id (e.g., 001), find all houses that meet the buyers preferences, with the results shown in descending order of price.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

4. What actions should Bouleau & Huntley take now?

Answered: 1 week ago