Sei sulla pagina 1di 25

Database Design

Exercises
Miguel Rebollo

Introduction to Computer Science


2010-2011
Example 1

Given a department code, obtain their name,


director and their employees, with their name,
category and dedication.

4626. Introd to Computer Science


Example 2

For a teacher code, determine his name,


dedication and category. Furthermore, obtain the
set of subjects that he teaches, with its code,
name, school and number of hours.

4626. Introd to Computer Science


Example 3

For a given provider, we want to know its name,


address, city and state, and the pieces that they
supply, with their colour, category, price and
quantity. All items of the same category have the
same price.

4626. Introd to Computer Science


September 2000
Design a relational database that match the
following requirements:
1. For a river, to know its name, total length, sea in
which it flows and the states it cross, storing their
name, extension and the km. that the river covers
through each one of them.
2. For each state, to store the name of their
bounding states and their capitals,
3. Determine the states without coast, with their
extension and their inhabitants.
4626. Introd to Computer Science
June 2001
Design a database to maintain the menu of a restaurant.
For each course, its name, a short description, its difficulty
level, a photo and the final price are stored.
Each course has a category. Categories are characterised
by their name, a short description and the name of the
employee in charge of them.
Besides the courses, recipes are stored. They are formed
by the name of their ingredients, the required amount,
units of measurement (grams, litres,) and the current
amount in the storehouse.

4626. Introd to Computer Science


September 2001
For the next edition of the Spanish Cycling Tour, a newspaper wants to
create a database to maintain information about this trial. In the
database, information about cyclist, teams and trials must appear.
For each cyclist, name, nationality, date of birth, the team to which they
belongs to (with he initial and ending contract dates) are stored. For
the team, its name, nationality, headers name are stored. For each trial
in which the team has participated, the name, year, number of stages,
total length (in kilometres) are stored.
Besides, we want to know the position of the team at the end of the
tour and the name of the winner.

4626. Introd to Computer Science


June 2002
You has just begun your collection of movies and you want
to create a database to store a list of credits.
For each film, you need its title, year, nationality and some
data about its director: name, date of birth and country.
Furthermore, we want to know if it is b/w or coloured,
recommended age, abstract and an additional field to put
your own remarks.
The list of credits must include the casting. For each actor
or actress, their names, nationality and name of the film
character are stored too.

4626. Introd to Computer Science


September 2002

You need a database to manage information about the magazines that


you buy habitually.
For each magazine, its title, the ISSN (code that identifies the
publication), number and year are stored.You need also data about the
articles, including its title, page of beginning and page of ending. It is
assumed that there are no two articles with the same title.
Every article can be written by several authors, whose name, e-mail
address and ascription are stored, Besides, a number that indicates the
order of firm have to be stored.

4626. Introd to Computer Science


June 2003
An ONG wants to prepare a database for all its projects. It has diverse
head offices in several countries which take manage and coordinate the
projects of that country.

On head offices, an identifier, the city and country where it is located,


its address, a phone number and the name of the director are stored.
Every head office manages a set of projects, with a code, a title, dates of
beginning and end, the assigned budget and the name of the person in
charge. One project is formed by a set of actions that can affect to
several cities

We want to know what actions are realised in each city, storing its
name, country and n of inhabitants. We also need an identifier to
differentiate them. Also there is wished the investment of the project
that corresponds to the city and a small description of the action.

4626. Introd to Computer Science


September 2003
A company that rents vehicles wants to know in real time the state of
his fleet. The company has diverse offices distributed by the whole
Spanish territory. Each office is identified by its code and it is
characterised by the name of the city, its complete address (street,
number and postal code) and phone.
Each office has a set of available cars, of which his license is known, the
group to which it belongs: A, B, C, D, E, F or G (it depends on the type
and size of the vehicle), the brand, the model, the number of doors, the
number of seats, the capacity of the trunk and the minimal age required
for renting.
To control the state of every vehicle, the company has a record of all
the rents that the car has suffered, indicating the name of the driver, his
DNI, address, a phone contact number and a credit card number.
Furthermore, for every rent, its duration (in days), the type of
insurance and the final price are stored.

4626. Introd to Computer Science


June 2004
A zoological park wants to construct a DB to organise the species that
it has and the different itineraries to visit the park. The information is
structured as follows.

For each species, we want to know its common name and its scientific
name, as well as a general description and a photo. Every species can
live in different natural habitats defined by his name, climate and
predominant vegetation. Every species has associated an index of
vulnerability inside every habitat, which measures the risk of extinction
of the species in the above mentioned habitat.

To organize the visits, and according to the habitats that visitors wants
to cover, the park offers them a series of trips for the habitats, which
are identified by their code and are characterised by their duration,
length and maximum number of authorised visitors. A habitat only can
be part of one itinerary.

4626. Introd to Computer Science


September 2004

A health centre need a DB with the case history of all its patients.
The health centre is divided into several units, each one having an
identifier, a name and the floor in which it is located. The unit has a
doctor in charge, characterised by his/her name, code and speciality.
When patients arrive, they are admitted in a unit and are registered
with their SS number, age and date of admission. While they are still in
hospital, all interventions realised by doctors are written down, setting
the date, the observed symptom and the prescribed treatment.

4626. Introd to Computer Science


June 2005
A property development firm wants to create a database to record its
housing promotions. A housing promotion is characterised by an
internal code, its name, the place in which it is located and a situation
map.
Every promotion is formed by a set of housings. Each housing has an
identifier, area (m2), number of rooms, number of bathrooms, the draft
(plane), a photo and its price. Also it is necessary to indicate if it has or
not yard, private garden, swimming pool and garage.
For the construction, publicity and selling of a promotion, the property
firm can hire different companies. For each company, to store its name,
type, postal address, phone, fax and e-mail it is desirable. Besides, the
amount of the contract between the company and the property firm
will be stored.

4626. Introd to Computer Science


September 2005

A health centre need a DB with the case history of all its patients.
The health centre is divided into several units, each one having an
identifier, a name and the floor in which it is located. The unit has a
doctor in charge, characterised by his/her name, code and speciality.
When patients arrive, they are admitted in a unit and they are
registered with their SS number, age and date of admission. While they
are still in hospital, all interventions realised by doctors are written
down, setting the date, the observed symptom and the prescribed
treatment.

4626. Introd to Computer Science


June 2006
An auction house wants to maintain a database to register all its
transactions.
Products sold at auction are grouped in sets. Each set has a catalogue
number, start price, highest bid and remaining auction time. Products
are characterised by a code, its name, a brief description and a
photography.
Customers that participates in the auction must bid for a set (bids for
individual products are not allowed). When a person bids, the amount,
the date and the hour are registered. Customers are identified by an
user name. Besides, they have a password, a name and an e-mail
address.
Create the conceptual and the logical scheme of the database that
fulfill the requirements expounded.

4626. Introd to Computer Science


September 2006
A transport company has available a fleet of buses which are
distributed in different routes. The company wants to create a
database to keep information about these routes.

A route is identified by a code. The total length (in km.), the source
and the destination of each route is stored. Besides, each bus has a
license number, a model, its capacity (number of passengers) and
the name of its driver. We assume that a bus can only be covering
one route.

Routes cover several cities. Well store the name of the city, the
address and the telephone number of the bus station. To keep the
stops organised, each bus stop has a order number. This number
can be different depending on the route the city belongs to (one city
can belong to several routes).

4626. Introd to Computer Science


June 2007
A company that provides photo storage on the web needs a database
to keep all their resources.

The photos are characterised by their URL (it's unique) and they have
a filename, data type, size, resolution and a field that sets if the
photo is public or private.

Users add as many tags as they need to each one of their photos to
classify them. Each tag keeps the total number of pictures that use
the tag. Besides, the system can suggest additional tags, so we need
to indicate who has added the tag: the user or the system.

To identify the users, a username and password is stored, together


with their email address.

Create the conceptual and the logical schemes of the database that
fulfills the requirements expounded.

4626. Introd to Computer Science


September 2007
You need a DB with links to the web sites you visit to keep an
historic more exhaustive than IExplorer Favorites.

For each web page, you will store its URL (web address), its name, a
short description and a global valuation.

Pages are grouped by categories instead of using folders,so each


page can belong to several categories. Each categories have a name
and keeps a list with its corresponding web sites and the association
date.

To know the navigation history, each time a web site is visited, an


entry will be added to the database with the access date and
permanence time. Visits have a unique order number associated to
them.

Draw the conceptual and the logical schemes of the database that
fulfills the requirements expounded.

4626. Introd to Computer Science


June 2008
A small florist wants to spread its business and have presence in
Internet and they need to create a database.

Orders are identified by its number and they contains the date, the
total amount and a list with the flowers included in the order and
their quantity. Flowers are identified by a code, their name and the
retail price. Flowers belong to an species. Species have a name,
flowering period, planting season, appropriate soil and
recommended sun exposure.

Create the conceptual and logical model that corresponds with these
requirements

4626. Introd to Computer Science


September 2008
A research center has to get information about pollination processes
in a concrete area, so it needs to create a database.

Flowers are identified by a code, its name, a description and a photo.


Flowers belong to a specie. Each specie has a name, flowering period
(blooming), planting season, appropriate soil and recommended sun
exposure time.

Each flower can be pollinated by different agents (physical, as wind,


or animated, as insects o birds). For each agent, its name, type and
subtype is stored. Flowers can use different decoys to attract
different agents (colours, shapes, scent -smell-,...)

Draw the conceptual and the logical schemes of the database that
fulfill the requirements expounded.

4626. Introd to Computer Science


June 2009
Lendmemoney.com is a money lending company that manages
lending among people (p2p lending).

Lenders that lend they money are registered with an id, their name
and their available amount of money for the financial operations.
Borrowers are identified by their id and the company registers their
name and a risk value depending on their personal situation.

When borrowers apply for a loan, a new loan code, the total amount,
the refund deadline, the interest rate and its purpose are stored in
the database. Lenders choose the amount that they want to invest in
each loan. A lender can contribute with different partial amounts to
several loans.

Create the conceptual and logical model that corresponds with these
requirements.

4626. Introd to Computer Science


September 2009
Social networks as Facebook use profiles to store information about
their users. Create a simple database to store these user's profiles.

Users have a nick (unique), a password, their real name and a valid
email account. Users can write comments, which are composed by a
text and the publication date. Furthermore, users can appear in
photos. A Photo has a filename and an optional description. To tag
users in the photos, a frame is used. The coordinates of these
frames are stored in the photo too in order to know which users
appear in each photo.

Create the conceptual and the logical models.

4626. Introd to Computer Science


June 2010
An airline needs a database to organise the information related with
its flights.

Flights are characterised by an Id, the departure date and the


departure and arrival airports. Each flight as one plane assigned to it.
Planes have a registration number (similar to a license plate) that
identifies them, the name of the manufacturer, the model, the
seating capacity and the flight autonomy (hours). Each flight has a
crew assigned to it, formed by a list of members of the staff of the
company. Each worker has an Id, a name, a professional category
and the position held in each flight.

Finally, each flight has a list of passengers in which their name,


passport number, seat and class (tourist, first or business) are
stored.

4626. Introd to Computer Science


September 2010
An airline needs a database to register information about its flights.

Flights have a unique identifier. Furthermore, each flight has a origin


and a destiny airport assigned (considering only direct flights).
Airports are identified by three letters (VLC-Valencia, BCN-Barcelona
and so on). Besides that, for each airport, the name of the city and
the country are stored.

Planes are assigned to different flights. A plane is identified by a


registration number, the manufacturer, the model and information
about its capacity (max. number of passengers) and flight range
(measured in hours).The assignment of a plane to one flight is not
unique, so to store the date is needed too.

4626. Introd to Computer Science

Potrebbero piacerti anche