# CMPT 260 Assignment 4

\$30.00

## Description

1. a. Determine whether the function f:Z→Z defined by f(x)=4x is
i. One-to-one
ii. Onto
iii. Bijective
iv. Find the inverse function if it exists. (2 marks)
b. For f(x)=2x+3 and g(x)=-x2+1, find the composite functions defined by
I. (f∘g)(x)
II. (g∘f)(x) (2 marks)
c. Given that f(x)=x/(5x+1) define the domain for f(x) to be a well-defined function. Assume that f(x) is one-to-one and onto over this domain.
I. Does f-1(y) exist? Explain.
II. Determine f-1(y) if it exists. Show your work (2 marks)
2. a. Construct an algebraic proof that for all sets A, B and C, ((A-B) –(B-C)) is equal to A-B. Cite a property from Theorem 6.2.2 (Set Identities) for every step. (2 marks)
b. Use the element method to prove that A–(A–B)=(A∩B). The element method uses statements such as x∈(A ∩ B) or (x∈A and x∈B). Provide a reason for each step including any identity used. (2 marks)
c. Let X = {1, 3,5,7,9}, Y={3,6,9, 11, 12}, W={1,2,3,4,5,6,7,8,9,10} and U={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}. Find each of the following (0.5mark each, 2 marks in total)
I. X-Y∩Wc
II. Y∪W
III. Wc
IV. X∩W
3. You are to do a number of queries on a database with the following tables: (8 marks)
• APT BUILDING (building id int, name varchar(20), address varchar(20), zone int, primary key (building id) );
• SUITES (suite id int, building id int, bedrooms int, rent int, occupied boolean, primary key (suite id));
• TENANT (name varchar(20), suite id int, year of birth int);
These tables help an apartment rental management company look after a number of apartments. The APT BUILDING table contains the id, name and address for the apartment buildings as well as which zone each is in. The SUITES table contains information about all apartment suites in the buildings. In particular each suite is identified by a suite id and information is given as to which building the suite is in as well as the number of bedrooms, the rent and whether it is occupied. The TENANT table contains the names and years of birth of tenants. Each tenant tuple also indicates a suite id.
Below are a number of queries. For each query, express the query in MySQL. Submit a text document that contains the MySQL queries executed and their output in interactive output format. This can be done in batch mode or via a mysql script, but for this small assignment it is probably just as easy to copy the command and output from your interactive window running mysql and paste it into a text document.
Note that you will probably want to initially type your commands/queries into a second text file, so that when an error occurs it is easy to edit them and recopy them into the interactive window to try them again.
In order to execute your MySQL queries, you will need to first create the 3 tables. In addition, you will need to fill the tables with their data. With this assignment, there are four text files: a5tables.txt, apt.txt, suites.txt, and tenant.txt. The first contains the sql commands to create the tables, and the other three contain test data to be loaded into the three tables. The way to load the APT BUILDING data is as follows:
load data local infile ’apt.txt’ into table APT BUILDING;
assuming that the file apt.txt is in the current directory (log into mysql when in the directory that contains the files). The other two are similar. The mysql system expects that the files use LF for end-of-line, and the tab character is used to separate the attribute values of one tuple. The data files have been set up in this way, so be careful not to change the file content.
Of course, before you start your queries, you should output the description and contents of each table to ensure that everything was set up correctly. Include this output with your assignment.
The required queries are:
i) How many vacant 2 bedroom suites are being managed?
ii) Give the addresses of buildings in zone 1 that do not have any suites renting for more than \$1000 per month.
iii) Give the names of buildings with no vacant suites.
iv) Give the names of the tenants that are renting in the building called sutherland tower