|
Williams | Learn Data Modeling by Example - Chapter 2 |
62 |

Frederiksborg Castle in Denmark
This is a tutorial on data modeling for young people that represents a typical data modeling project and illustrates the basic principles involved.
In this tutorial, we will follow two young tourists as they visit Denmark, which is a country with a tremendous history and is very popular with tourists looking for something special.
Our
tourists are Isabella,
a 10-year old girl, who likes sightseeing and ice cream
and
Benny,
Dimple's 12-year-old brother, who likes sightseeing and designing
data models.
Data modeling is important because it is the foundation for so many activities:
It provides a vehicle for communication among a wide variety of interested parties, including management, developers, data analysts, DBAs and more.
A physical database can easily be generated from a data model using a commercial data modeling tool.
You will learn:
How to create a data model, starting from scratch
The important design principles involved
What a typical data model looks like
In this chapter, we will cover some basic concepts in data modeling:
Primary and Foreign Keys
One-to-Many and Many-to-Many Relationships
Hierarchies and Inheritance
Reference Data
2.5
Let’s get started
[Toby]:
We have just arrived in Denmark. What would you like to do today?
[Dimple]: Toby, It's great being in Denmark which has so many things to see and enjoy.

[Toby]:
I'm glad you like it, Dimple. What would you like to do today?
[Dimple]: Toby, we have come to Denmark, and I would like to see
as many of the Tourist Attractions as we can. then I would like to do
some shopping, take a trip on a Viking ship and I would like to
finish up at Starbucks at Copenhagen airport.
[Toby]:
OK. Let's go.
We are starting from Copenhagen, which is a very charming city.
2.6
Arriving in Copenhagen
[Dimple]
Wow, Toby, look at the people.
[Toby] Yes, Dimple, when we look around there are people, shops, banks and so on!
So we can start thinking about our data model.

[Dimple]:
How do we get started?
[Toby]: Well, we know that we have
people and places.
The simplest start is to call all these places
establishments.
Then we simply have different kinds of establishments.
And
we have people - local people, tourists, students, people passing
through, people working here, people here on business and so on.
[Dimple]: Hmmm - so how do we translate what we know to help
us get started with our data model?
[Toby]: Let’s start a diagram with people and establishments.
This simple diagram is going to grow into a data model.
![]()
2.8
Identifiers and Primary Keys
[Dimple]:
Toby, I am one of these people so how
do I create a unique identity for myself to make me different from
everybody else?
[Toby]: We will give every person a unique
identifier
and every establishment its own unique identifier.
When
we use these we call them Primary
Keys,
and show them in the diagram with a PK
on the left-hand side.
[Dimple]: That sounds good, Toby, but
I don't know what it means.
[Toby]: Well, Dimple, let's look
at how we use these identifiers...

We have found a wonderful shop in Copenhagen called Loegisemose where we find a customer choosing from the wide variety of delicious goods on display.
So, in other words, we have one customer, and one establishment, which is the shop.
So we can create a people record with a person ID of 1 and an establishments record for the stall, with an establishment ID of 2.

Customer at Loegisemose - http://loegismose.dk/
2.9
Relationships and Foreign Keys
[Toby]:
Dimple, now we can add some interesting details because we know that
one person can visit many establishments.
We also know that one
establishment is visited by many tourists.
Then we call this a
many-to-many
relationship
between people and establishments.
To make it easier for you
to understand I have expanded the many-to-many
relationship
into two different things, which are called one-to-many
relationships.
[Dimple]: So Toby, is that like saying that one person can
make many visits to many establishments?
[Toby]: Yes, Dimple
- that's great - and we can also say that one establishment can have
visits from many people.
At this point, we can show how all
these boxes are related, and that is a very big step, because it
takes us to the idea of 'relationships'.
We can call these boxes tables - or entities if we want to speak to professional data modelers.
A table simply stores data about one particular kind of ‘Thing of Interest’.
For example, people or establishments.
Each record in a table will be identified by its own unique identifier, which we call the Primary Key.
It is not usually easy to find a specific item of data already in the table that will always be unique.
For example, in the States, Social Security Numbers are supposed to be unique, but (for various legitimate reasons) that is not always the case.
Also, foreign visitors and tourists will not have SSNs.
Therefore, it is best practice to create a new field just for this purpose.
This will be what is called an auto-increment data type, which will be generated automatically by the Database Management System (DBMS) at run-time.
This is called a surrogate key and it does not have any other purpose.
It is simply a key that stands for something else.
It is a meaningless integer that is generated automatically by the database management software, such as Oracle or SQL Server, The values are usually consecutive integers, starting with 1,2,3,4 and so on.
Now we can see how useful our identifiers can be because we can include the person and establishment identifiers in our visits table.
Then
the Person_ID field becomes a link to a record for a person in the
Person Table.
This link is what is called a Foreign
Key
and we can see it's shown with 'FK'
on the left-hand side.

2.10
Staff, Establishments and Derived Fields
[Dimple]:
Toby, how do we specify that staff must work in some establishment?
[Toby]: Dimple, that's a very good question.
Fortunately,
the answer is very easy.
We add a one-to-many relationship
between the staff and establishment entities
In English, we would
say that every member of staff must work in one establishment and
every establishment can employ many members of staff.
In the
diagram, we show this with a Foreign
Key
by the Establishment_ID field in the staff entity.
So if we look
closely at the staff entity, we will see 'FK'
by the Establishment_ID field.
[Dimple]: OK, that sounds
good, and I can see how the identifiers are very important.
[Toby]:
I am glad to hear it, Dimple.
There is one more thing I have to
say.
We are learning data modeling and one important thing about
data modeling is that it has to follow a set of rules.
These rules help us to produce good data models and so they are
very important.
One of the rules is that we cannot include any
bits of data that can be derived from any other bits of data.
For
example, we usually want to know how many people work in a shop or
cafe.
Therefore we include a staff
Count
field with the establishment.
But when it comes to finding the
value that goes in here, we will count the records in the Staff Table
for each establishment.
Therefore, it's a derived
Field
and we call it a name that starts with 'derived_' to make things
clear.
This is because, according to the rules, we should not
include derived fields in our data model at this early stage.
I have shown it here simply as an example because it is a situation that occurs quite often so it’s good to recognize it when you see it.
Does
that sound sensible, Dimple?
[Dimple]:
I suppose so, Toby. But I've got a headache, can we go to Starbucks
now?

2.11
Products and Product Types
[Dimple]:
Toby, when we go into a shop we want to buy something.
There are
often hundreds and hundreds of possibilities.
How do we deal with
all that in our little data model?
[Toby]: Well Dimple, it's
really quite easy. It's like all our modeling where we look for
simple patterns that cover many situations.
[Dimple]: Hmm - I
don't know what that means. Maybe if you showed me I might understand
it.
[Toby]: OK.
Everything that we buy is called a
product, and all we have to do is simply define the type of each
product - such as a coffee, muffin or a newspaper.
Then
we draw a little box called Products
and say that every product has a type.
In other words, there is a
relationship between the Products
and Product_Types
boxes.
The
lines are called relationships
and they are very important in data modeling.
We are now creating
an Entity-Relationship
Diagram
or ’ERD’.
This diagram shows only a line for the relationship:
![]()
The symbol at the products end is called crow’s feet and it shows the many end.
The short straight line at the Product_Types end shows the one end.
In other words, this line shows a one-to-many relationship.

Dimple, let me explain about the dotted line. It means that the relationship results in a foreign key in the Products Table. This is shown by the ‘FK’ symbol next to the product_type_code field and it means that there is a link back to the Product_Types.
However, the primary key is only the Product_ID, and of course, this is shown by the ‘PK’ symbol next to the Product_ID field.
Later, when we talk about inheritance, we will use a straight line, in contrast to this dotted line here. This is to show that the foreign key field is also a primary key.
I have to say something a bit difficult about primary keys right now.
In the Products Table, we have to allow for a very large number of products being stored.
Therefore we use an ID field for the Primary key.
We then create this ID field automatically as a number (called an auto-increment integer).
This number has no meaning and is simply used to identify each record uniquely among possibly millions or hundreds of millions.
However, things are different for type fields.
These are what we call enumerated data and are typically reference data.
They are always relatively small in number and we choose a code for the primary key because we can create them and review them manually.
It also helps us to create a code that we can use and refer to, in contrast to the ID fields that have no meaning.
Typical examples would be:
Sizes – Small, Medium and Large where we are accustomed to seeing S,M and L.
Gender – Male and Female, where we use M, F and U for Unknown.
2.12
Products and Hierarchies
We
stop for a coffee at one of the two Starbucks in Copenhagen airport.
This menu board at Starbucks shows lots of products.
We know that they are organized in groups, like food and drink, and each of these has more groups and so on, right down to the particular product, like caramel macchiato or a panini.
This top-down organization is called a hierarchy and appears all over the place.
Luckily we can show this very easily and neatly in our data model.

[Dimple]:
Toby, when we look closely at the menu board to try to decide what to
order we can see lots of possibilities. But after a while we can see
a pattern that helps us decide.
How do we deal with all that in
our little data model?
[Toby]: Well Dimple, it's really quite
easy.
We define something called a hierarchy.
Hierarchies are very common and simply mean any situation where
there are parents, children, grandchildren and so on.
If we look
at the Starbucks menu board on the right-hand side we can see a
simple example of 'espresso' and under it a number of different
drinks.
My favorite is caramel macchiato.
So in this case,
the top-level of our hierarchy is a product category called espresso,
and the next level down is a product called caramel macchiato.
[Dimple]: OK. That sounds OK.
[Toby]: Finally, we
show this hierarchy by a dotted line in the top-right hand corner in
the entity called 'Ref_Types_of_Products'.
This is formally called a recursive or reflexive relationship and is informally called rabbit ears.

2.13
Types of People and Establishments
[Dimple]:
Toby, that looks OK.
I guess we can deal with types of people the
same way, can we?
[Toby]: Yes, Dimple, and types of
establishments as well.
[Dimple]: OK, that sounds sensible.
And do they use these identifiers in a database?
[Toby]: Yes,
and what is even better is that the database will automatically
generate a new unique identifier for you and your visits and
purchases if you want to get a refund later.
[Dimple]:
Toby, that looks OK.
I guess we can deal with types of
establishments the same way, can we?
[Toby]: Yes, Dimple.
[Dimple]: OK, that sounds sensible. And do they use these
identifiers in a database?
[Toby]: Yes, and we can use our
new unique identifier for you and your visits and purchases in case
we want to keep track of things.
Like
maybe you want to get a refund later so we need to get your details
from the database.
[Toby]:
Before we move on, let's talk about establishments.
In Denmark,
there are many different kinds of establishments, like shops, banks,
cafes, restaurants, hotels, hospitals, garages and so on.
But
when we think about these things, we find that we can simply fit them
into our definition of establishments and identify them as different
types of establishments.

2.14
Visits and Purchases
Here
we can see a customer browsing through the Wine department in
Loegisemose in Copenhagen.

[Dimple]:
Toby, with so many tourists, stalls, shops and things to buy, how do
we keep track of everything?
[Toby]: Well, Dimple, by this
time, everything has its own identifier
that we can use whenever we need to keep track of individual people
or purchases or products.
[Dimple]: OK, that sounds sensible.
And do we use these identifiers in a database?
[Toby]: Yes, Dimple, and in this diagram, we can see that we can use the unique identifiers that are shown as ‘PK,’ for primary keys.
We can see that we have a PK for every entity or table so we can be pretty sure we can get from any table to any other table.
This is called navigating around the data model and is a good test for a well-designed data model.

2.15
Tourist Attractions
and Inheritance
[Toby]:
Dimple, let's take a closer look at the different types of Tourist
Attractions we can find in Denmark.
[Dimple]: OK, Toby. I
hope I don't have to think too much because I might get a headache?
[Toby]: No, Dimple, I will do the thinking and talking and
all you have to do is nod your head when you understand.
[Dimple]:
OK, Toby. I promise to do that.
[Toby]: We already said that
we have a lot of people visiting the Tourist Attractions.
There are lots of different Tourist Attractions and it is interesting to think about what they have in common and what they have that makes them different.
[Dimple]: OK, Toby. How do we get started.
In
data modeling we have a very powerful approach that we call
Inheritance
that we can use here.
In
this Section we look at different kinds of Tourist Attractions and
how we can use them to talk about Inheritance.
All Attractions have some characteristics in common, such as :-
Name
Description
Location
Opening Hours
Address
Contact Details
Directions for How to Get there
In addition, specific Categories of Attractions have some additional data of their own.
Some of these can simply be included in the Description, but some others justify being added as specific names fields.
For example :-
Churches
Religious denomination
Special awards, eg UNESCO World Heritage Site
Christmas Decorations
Danish Royal Family
Royal Protocol and Procedures
Hotels
Number of Rooms
Number of non-smoking Rooms
Museums
Exhibitions from time to time
Restaurants
Type of food
No-smoking area (Yes/No)
Licensed to serve alcohol
Stars or other awards
Shops
No additional data
Egeskov Castle was constructed in 1554 in the middle of a lake.
A park was designed in 1700 and there you will find the century’s-old hedges, peacocks walking in freedom and well-groomed English gardens.

This is a beautiful picture of the Castle that does not look so imposing from this angle.

This Castle is mentioned in Shakespeare’s Hamlet.
Web Site - http://www.copenhagenet.dk/CPH-Kronborg.htm

The historic Rosenborg Castle dates from 1506.

This beautiful Church has been established since 1848 :-

This striking building is a UNESCO World Heritage Site which definitely makes it worth taking a look.
Here is the Trip Advisor Web Site :-

This is the Most Decorated House once a year anyway !!!
In Roskilde one of the inhabitants is very well-known for lighting up his house with an extensive range of Christmas lights.
They have become a Tourist Attraction in their own right which has caused a number of complaints from his neighbours.

The Royal Family plays a very important part in Danish society.
It is one of the things that make Denmark unique and the Danish people are naturally very proud of their royal tradition.
This extract is taken from the Danish Monarchy Web Site –
The Danish Royal House is the oldest in Europe and may be traced back to Gorm the Old (deceased 958).
The first representative of the House of Oldenborg became King in 1448, and the last King of the House of Oldenborg was King Frederik VII, as he had no heir to the throne.
In 1863, the first representative of the House of Glücksborg became King, and the present Royal Family are direct descendants of this Royal House.
King Christian 13. died in 1947 and was succeeded by his eldest son, Frederik 10. who had married the Swedish Princess Ingrid in 1936. They had three daughters, Princess Margrethe (born 1940), Princess Benedikte (born 1944) and Princess Anne-Marie (born 1946).
The current monarch, "Queen Daisy" as she is fondly dubbed by her subjects, with whom she is extremely popular, is the great-great-granddaughter of King Christian IX.

From left: Crown Prince Frederik, Princess Isabella, Crown Princess Mary, Prince Christian, Queen Margrethe II, Prince Henrik, Prince Felix, Prince Nikolai, Princess Marie,Prince Joachim
The Royal Family split their time between a number of Palaces.
In summer, the Queen and the Prince Consort reside at Marselisborg Palace, Graasten Palace or on the Royal Yacht Dannebrog. Most of the palaces are historically the property of the Royal House. However, with the introduction of the Constitution in 1849, the palaces passed to the Kingdom of Denmark. The Palaces and Properties Agency is responsible for the management and maintenance of many of the royal palaces and gardens. Some of the palaces are the private property of the Royal Family.

Amalienborg Palace
In winter, HM The Queen and HRH The Prince Consort reside at Amalienborg, whereas their residence in spring and autumn is Fredensborg Palace.

Fredensborg Palace
Fredensborg Palace was built for King Frederik IV in 1710.
The Royal Family Tree looks like this :-

This is a simple Model that covers direct relationships from Children to Parents.
The Royal Family can be shown in a Data Model as a Hierarchy.
This means we can show it very simply in one table with a relationship to itself.

You can check out the Genealogy and Family Tree Data Model on our Database Answers Web Site :-
This is a complex Model that includes a ‘Relationships’ to provide flexible relationships from Children to Parents, Brothers to Sisters and Husbands to Wives.

This picture shows the Royal Life Guards outside the Palace in Copenhagen.
They are on duty when the Queen is in residence.

This is a very beautiful and unique Hotel in Roskilde which is about 30 minutes by train from Copenhagen
Roskilde is a charming and very historic town which dates back to the 8th. century and was the old capital of Denmark, where the King used to live.
We have included the hotel with Tourist Attractions because it has a very interesting history.
We stayed in the hotel and found the staff always friendly, courteous and helpful, especially a young guy called ETEM, who doubled as PC Technical Support specialist and Receptionist.
This hotel, in fact, used to be the center of government for Denmark in those days.

Here is the Hotel Web Site –
You can check out reviews on the Trip Advisor Web Site :
This is a charming and well-run Museum featuring local artefacts that serve to emphasise the long history of the region
Here is the Museum Web Site :-

The beautiful Front Door of the Roskilde Museum
The Roskilde Music Festival is an annual Event that was started in 1971 by two high school students.
It that attracts rock music fans from across the Nordic countries and features world-class performers like Bruce Springsteen (in 2012).
Here is the Web Site (in Danish) –
And here is what Wikipedia has to say :-

The photo shows thousands of fans enjoying the last night of the Festival.
Noma is a world-renowned Restaurant and was voted Best Restaurant in the world in 2010 and 2011 with a reputed waiting list of 2 years and a price of $500 for dinner.
Trip Advisor recommends Noma like this :-
And here is their Web Site :-
It was too expensive for our holiday budget but we enjoyed going in to ask when we could get a reservation ;-)
We found NyHavn much more to our liking (and our budget) ;-0)
NyHavn is a whole street of excellent restaurants.
It took us a while to realise that is pronounced ‘New Hown’.
Then we understood why nobody could tell us where to was because we were pronouncing it ‘New Haven’ !!!
It is very old part of Copenhagen and was called the New Harbour in the 17th. Century.
When we look around we can see there are so many people, boats, beautiful house and so on !!!
Here is what Wikipedia has to say about NyHavn –

The beautiful street of Nyhavn is packed with great restaurants
Japanese food and Sushi in particular is very popular in Denmark.
One of the best Sushi restaurants in Copenhagen is Sticks ‘n Sushi which is a chain of about 10 Restaurants and is planning to open up in London and we are sure it will do very well.
We went there a few times because the food is excellent and the service is friendly.
One day we walked there for 45 minutes because my wife said the exercise would do us good.
When we got there we were told there would be a 45 minute wait so we turned right around and walked 45 minutes back ;-0)
Here is what Trip Advisor has to say :-

A
beautiful plate of Sushi at Sticks ‘n Sushi in Copenhagen
Loegisemose is a beautiful Shop in Copenhagen offering a wide variety of excellent goods.
Here is their Web Site :-

A Customer browsing at Loegisemose
Nimb is part of the Tivoli complex in the centre of Copenhagen and includes a variety of attractions for the tourist, including a Hotel, Restaurants and a Wine Bar.
This beautiful photo shows you what it looks like :-

And here is their Web Site :-
This shows Stroget, which is the main shopping street in Copenhagen.
It is the world’s longest pedestrian shopping street at more than a kilometer in length and has been established since the 1800’s.

[Dimple]
: Toby, with so many Tourists, Shops and things to buy, how do we
keep track of everything ?
[Toby] : Well, Dimple, by this
time, everything has its own Identifier that is used wherever they
need to keep track.
[Dimple] : OK, that sounds sensible. And
do we use these Identifiers in a Database ?
[Toby] : Yes,
Dimple, and in this diagram, we can see that we can use the unique
Identifiers which are shown as ‘PK’, for Primary Keys
There are always lots and of People visiting Copenhagen.
When we look at this typical street scene, we can see Shoppers, Stallholders , Workers and local people
We
usually know different things about the Stallholders and Workers than
the things we know about the Tourists.
For example, we will
probably know the Gender of everybody just by looking at them.
For
Workers, we will might also know things related to their employment,
such as their Date of Birth and their Home Address.
In Data
Modelling we have a very powerful approach that we call Inheritance
that we can use here.
If we want to describe this in English, we
would say that Staff inherit the People_Type_Code and Gender from the
parent Entity of People, and in addition, they have a Date of Birth
and Home Address.
For Tourists, we don’t know much, except for the Date of their Visit, and maybe, if they buy something in a shop using a Credit Card, then the shop would know the Credit Card details.
Does
that make sense, Dimple ?
[Dimple] : I think so, Toby.
Is
it like saying that we inherit having two arms and two legs from our
Parents because they have two arms and two legs, but that we have
also have things that are just us ?
[Toby] : Yes, Dimple -
that's great - let's take a break and do some shopping !!!
[Dimple]
: I like the sound of that, Toby. Can I have an ice cream ?
[Toby] : Yes, of course, Dimple – this diagram shows we are doing well.
It show Inheritance between People and the two different types of People :-
This picture shows the proud tradition of Vikings in the 17th. Century.

Offshore at Roskilde
When we look at the data for our Tourist Attractions this is what we find :-
General
Data
Name Description Phone
Number Email
Address Location Opening
Hours Address Contact
Details How
to Get There
Photos Title Description Filename

Churches
Awards Denomination


Museums Exhibitions
Christmas
Decorations
No
additional Data

Restaurants
Awards No
Smoking Area (Y/N) Serves
Alcohol (Y/N) Type
of Food


Danish
Royal Family Ceremonies Family
Tree

Hotels Number
of Rooms No-smoking
Rooms (Y/N)
Shops
Late Night Opening Hours

This is how it looks in a Data Model, showing Attributes for each Table :

This diagram is a more complex version showing only Entities but with additional tables :-

You can see that the Model is much more compact and when you are accustomed to looking at Data Models and know what to look for, it tells you a a lot in a small diagram.
If we want to describe this in English, we would say that staff inherit the People_Type_Code and gender from the parent entity of people, and in addition, they have a date of birth and home address.
For tourists, we don’t know much, except for the date of their visit, and maybe, if they buy something in a shop using a credit card, then the shop would know the credit card details.
Does
that make sense, Dimple?
[Dimple]: I think so, Toby.
Is
it like saying that we inherit having two arms and two legs from our
parents because they have two arms and two legs, but that we have
also have things that are just us?
[Toby]: Yes, Dimple -
that's great - let's take a break and do some shopping!
[Dimple]:
I like the sound of that, Toby. Can I have an ice cream?
[Toby]: Yes, of course, Dimple – this diagram shows we are doing well.
It shows inheritance between people and the two different types of people:

We can see a field marked as ‘PF’ in the tables for staff and tourists.
This is unusual because it means a field that is a Primary Key in the three tables and also a Foreign Key to the People Table.
Therefore, if your first record was a member of staff, then we would have a record in the People Table with a Person_ID of 1 and a record in the staff table with a Staff_ID of 2.
Similarly, if our second record was a tourist, we would have a record in the Person Table with a Person_ID of 2 and a record in the tourist table with a Staff_ID of 2.
2.16
Design Patterns and Reservations
Design
Patterns are a very powerful technique when creating Data Models
because they represent a common solution to a range of similar
requirements.
In this example, we use a Canonical Data Model to implement the Design Patterns.
We will look at the specific example of making Reservations that we might make to visit Tourist Attractions during our visit to Denmark.
This is
our starting-point which is designed to be a universal Model for a
wide range of situations. CUSTOMERS

EVENTS
eg
Reservations
PRODUCTS
and SERVICES
SUPPLIERS eg Staff


LOCATIONS

DOCUMENTS
eg Tickets

Our first example is making a Hotel Reservation over the phone.
This involves talking to a member of the hotel staff and will not generate any documents.
For a hotel, of course, you would book for a specific night (or nights) and maybe a non-smoking room but that is about all.
I
CUSTOMERS

EVENTS
-
Make Hotel Reservations
HOTEL STAFF
SERVICES
Our second example is making an Online Reservation over the Internet for the Music Festival.
This does not involve talking to any member of staff and will allow us to print our Tickets.
Therefore, the staff of the Organisation does not appear in this version of the Design Pattern but the Documents entity does appear.
CUSTOMERS

EVENTS
-
Customer makes Reservations
SERVICES
- Online Reservations

DOCUMENTS
- Tickets

2.16.4
Generic Data Model for Reservations
In
this model, we define a facility to be what we are making a
reservation for.
This data model is shown on this page of our Database Answers Web site:

[Toby]: Dimple, this bit is quite hard-going so if you want to take a rest, that’s OK.
[Dimple]:
OK, Toby, I will just sit quietly and watch the people ;0)
[Toby]:
People make reservations every day all around the world.
These reservations have a lot in common:
The basic data include a date and time, a specific Facility, like a hotel, an airline seat, a theatre and so on.
This means that we can identify what they have in common and what they have that is different and specific to the type of reservation.
2.17
Reference Data
[Toby]:
Dimple, you can see that I am using a Gender Table and People Types
Table.
I have given them both names that begin with 'Ref_' to
make it clear that they are reference data.
This
means that the values don't change much and I can use them to define
what the valid values can be.
This is a technique that
professional data modelers use but we don't need to worry about it
today.
[Dimple]: I'm glad to hear it, Toby!
Although it
isn’t difficult to understand and it seems like a good idea.
[Toby]: In our small example, we have only four kinds of reference data altogether - gender, types of establishment, people and products.

2.18
Bringing it all Together
[Toby]:
Dimple, if we bring together everything we have talked about, we will
see that we have quite a good data model that any professional would
be proud of.
[Dimple]: OK, Toby. Do you think I will
understand it?
[Toby]: Let me help you by making a list of
the business
rules
for our model:
People can be either local residents, staff or tourists.
There are a number of establishments of different types.
Tourists can make visits to establishments and make purchases.
Staff assist the tourists when they make a purchase.
A purchase involves one or more products.
[Toby]:
OK, Dimple - we have a very nice data model and now we can take the
break I promised you.
[Dimple]:
That's great, Toby - can we go to Starbucks?
[Toby]: Sure,
but before we do I should say something about PF,
which appears in the Staff Table.
It's unusual and it's
called PF
because it means a field which is a Primary
Key in the Staff Table and a Foreign
Key to the People Table.
[Dimple]: Hmmm, I've got a headache,
Toby - can we please go to Starbucks?
[Toby]: OK, Dimple.
You've been a very good girl and you deserve a break.
You can admire what we have created, which is this very professional-looking data model.
2.19
Top-Level Model with Key Fields
This
is what our data model looks like if we show Key fields only and
leave out the Reference Data Tables. This
level of display is suitable if we want to confirm to how the tables
(or entities) are related. 
2.20
Starbucks
[Toby]:
Dimple, I've got some wonderful news for you.
[Dimple]: I'm
glad to hear it, Toby - what is it?
[Toby]: I have found
Starbucks at Copenhagen airport here in Denmark, so you can have your
favorite things to eat or drink ;)
[Dimple]: Toby, are you
teasing me?
[Toby]: No, Dimple – we can make a visit when
we take our flight back home after our interesting and enjoyable
visit to Denmark.
[Dimple]: Wow - that's great, so I can
have my favorite muffin.

Starbucks in Copenhagen Airport
In this chapter, we have learned how to think like a data modeler and how to gradually put together a data model in our heads.
We know that if we get in the habit of doing this regularly it gets easier and more natural and soon we will be seeing the world around us as pieces of a data model that we can fit
together like a jigsaw puzzle.