0% found this document useful (0 votes)
21 views

Task For BD02

The document describes two exercises to create tables for an estate agency using SQL. The first exercise has the student create tables for clients, properties, and visits with various data fields and constraints. The second exercise has the student modify the tables, adding and removing fields and constraints.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Task For BD02

The document describes two exercises to create tables for an estate agency using SQL. The first exercise has the student create tables for clients, properties, and visits with various data fields and constraints. The second exercise has the student modify the tables, adding and removing fields and constraints.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

RETAKE Task for BD02

Unit task details


Exercises
EXERCISE 1
We are going to create some useful tables for an Estate Agency. We will start by
creating the following tables with SQL using the following information:

 The CLIENT table includes information about the clients: client identifier,
identification card, name, surnames, register date, email, mobile phone,
nationality.

 The PROPERTY table includes information about the properties:reference


(number that identifies the property), location, price, type, number of bedrooms,
number of bathrooms, build area, plot size, features (long description about
garden, garage, sea view, community pool, parking, …), for sale (true / false).

 The VISIT table includes information about scheduled visits of clients to the
properties: visit identifier, visit date and hour (only one field for date and hour),
agent name, property, client identifier.

Consider the following:

a. Choose the most adequate attribute types depending on their content.


b. Establish the following constraints:
1. We can distinguish rows in the tables by the identifiers or references.
2. Email and mobile phone can not be repeated.
3. The property of the VISIT must be a reference to the PROPERTY table.
4. The client of the VISIT can only be a client identifierfrom the CLIENT
table.
5. The only information that can be empty is the plot size.
6. Build areamust be lesser thanplot size.
7. The type attributecan only take these values: Commercial, Finca, Land,
Penthouse, Townhouse, Villa.
8. The sale default value is false, and the default value for register date is
the current date.

EXERCISE 2
We are going to modify the tables created in the first exercise.
1. Create a pool field in the PROPERTY table. Its domain is C (community) and P
(private).
Establish the following constraints:
2. The price field must be equal to or greater than 100.000€.
3. The register date must be later than year 2000.
4. A visit cannot be inserted unless the hour of visit is between 9 and 15.
5. Remove the previous constraint about the visit date.
6. Delete the email column of the CLIENT table.
7. Two clients cannot have the same identification card.
8. Change the VISIT table primary key for thevisit date and client fields.
9. We want to ensure that every visit has only ONE client (that is, two clients can
visit the same property only at different time). Create a unique index to validate
that.
10. Rename CLIENT table for BUYER.
11. Remove the VISIT table.
12. Create a user with your name and a password. Give SELECT and INSERT
privileges on the PROPERTY table to that user.

Scoring criteria. Total 10 points.


EXERCISE 1: 4 points
 Correct syntax: 1 point (running without errors in the SQL editor)
 Correct data types choice: 1 points
 Correct constraint design: 0,25 points per section
EXERCISE 2: 6 points
 0,5 points per section

Resources needed to carry out the Task.


It could be useful to have installed the mysql server and workbench application to test
the answer.

Recommendations.
You will be using some new operators. Remember in the “Elementos del Lenguaje.
Normas de escritura” section you have the most common operators.

Useful information:
MySQL 8.0 operators

Submission rules.
Once the task is done, you will create a single document, the document should have the
answer of the exercises inside. The delivery of the document will be done through the
platform and the file document must be PDF named as follows:

Surname1_surname2_name_SIGxx_Task

Make sure the name does not contain the letter ñ, accents, or any other special
characters. For example, the student Begoña Sánchez Mañas for the second unit of the
subject BD, should name this task as...

sanchez_manas_begona_BD02_Task

You might also like