Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 38

COMP1556 – Week 3

Database Technologies
Applications

The science fiction case study and notation forms.

Andy Wicks (c) 2019 1


 Last Week 
• We went through the six steps to creating a
sustainable database.
• You found that it was MUCH easier than using
normalisation.
• It was also much more flexible because you
could add or delete tables as necessary.
• You saw that you could create the SQL easily.
Andy Wicks (c) 2019 2
 This Week 
• We will go through the six steps using
the science fiction case study …
• … which you have all read!
• This achieves two things:-
1. It re-enforces the use of the six steps.
2. It give us a platform to explore more
ideas.
Andy Wicks (c) 2019 3
The Sci-Fi Case Study
“You are a shower of incompetent idiots. That is,
you are even incompetent as idiots,” and I
slumped into my captain’s chair. In my heart of
hearts, I knew that I was at least in part to blame.
The crew of this space cruiser had “special needs”
– mostly revolving around drink - and food. I
stared at Mover Multhi whose arithmetic
incompetence had moved the contents of the on-
board latrine into my cabin rather than our ship to
Betelgeuse. Andy Wicks (c) 2019 4
The Sci-Fi Case Study
Oh, the hidden problems of warp drive! It
quivered, which is quite a feat for an alien with an
exoskeleton. It “hailed” from Tau 4, but was really
sickly, which it blamed on the diet. Tauforians are
omnivorous, but eat different foods in cycles, so
getting the right food at the right time is
important. Of course, this conflicted with the
dietary needs of, say, the Reechers – give them the
wrong food and the ship stank for weeks.
Andy Wicks (c) 2019 5
The Sci-Fi Case Study
This cruiser is home to 237 beings from 29 different
planets. Now, you try running a catering service that
keeps all of them happy.
 
Suddenly, I had an idea, but since that was not legal I
decided to try to organise their cuisine instead. I felt
a little Database coming on (this is legal, if somewhat
disconcerting – at least my concerting was dissed).

Andy Wicks (c) 2019 6


The Sci-Fi Case Study
Why would someone from the planet Database
find me attractive? No, please don’t answer
that. So, I decided to palm it off with a
Relational.
 
Design a database to cope with their dietary
needs.
Andy Wicks (c) 2019 7
Step 1 – Find the Objects
• Anything you can touch, e.g. an extra terrestrial.
• Anything you can list, e.g. food items.
• At stage 3 we will add any necessary intersection
entities.
• In LucidChart, we add a 3 column box for each
object.

Andy Wicks (c) 2019 8


Now we are off
to LucidChart

Andy Wicks (c) 2019 9


Step 2 – Link the objects
• We start with the left-most object.
• Check whether there is a link to each of the other
objects.
• Then move to the second object and check that
against each to its right.
• Repeat this until the last object.
Andy Wicks (c) 2019 10
Now we are back
to LucidChart

Andy Wicks (c) 2019 11


Stage 3 – Add Cardinality
• Which is the 1 and which is the Many?
• Try the relationship from both ends to check
the cardinality.
• We can have M-Ms and 1-1s at this stage. We can
sort them out later.
• For M-Ms, add an intersection entity.

Andy Wicks (c) 2019 12


Now we could go back
to LucidChart, but you
can do that!
Andy Wicks (c) 2019 13
Stage 4 – Add the PKs
• Each object gets a primary key (PK) with
it own name and “ID” at the end.
• Add these to each object …
• … with a smile.

Andy Wicks (c) 2019 14


Stage 5 – Add the FKs
• Check each object to see whether it has a
many link at its end.
• For each many link, add the PK from the 1
end.
• If Fred is at the many end of a link with
Mary, then it gets MaryID as a foreign key
(FK).
Andy Wicks (c) 2019 15
Stage 6 – Add the Fields
• For each object, go through and add any
necessary fields.
• Normally, this is where you would start.

Andy Wicks (c) 2019 16


We have …
• … a database design that is in 4NF.
• We have not had to rewrite the data list at all.
• There are no composite keys because each
object has its own ID primary key.
• The user never sees these PKs.

Andy Wicks (c) 2019 17


Now we can go back
to LucidChart to
make it look pretty
Andy Wicks (c) 2019 18
Crows-foot Cardinalities

Source : https://www.lucidchart.com/pages/ER-diagram-symbols-and-meaning
Andy Wicks (c) 2019 19
Active and passive verbs
• We can define the link between two entities
by using a verb to explain the relationship.
• What is a verb?
• A relationship could be described like this:-

Andy Wicks (c) 2019 20


Strong Entities
• A strong entity will exist regardless of
anything else to which it is linked.
• For example, you will exist regardless of
whether there is a university.
• Take the university away and you will still be
here.
Andy Wicks (c) 2019 21
Weak Entities
• A weak entity will only exist if the strong
ones exist.
• For example, an enrolment will only exist if
both you and the university exist.
• Take either you or the university away and
you cannot have an enrolment.
Andy Wicks (c) 2019 22
A weak entity looks like this …
• … it has a dashed edge.
• Intersection entities are usually weak.

Andy Wicks (c) 2019 23


Weak entities cause …
• … weak relationships.
• This is shown by a dashed line.

Andy Wicks (c) 2019 24


ERD Model Types
• Conceptual Model – Shows the entities, their
links and cardinalities, but may have M-Ms.
• It may show PKs and FKs and is used to talk to
the client.
• Logical Model – Also shows PKs, FKs and
fields.
• Physical Model – Shows the data types as well.
Andy Wicks (c) 2019 25
ERD Notation Systems
• See the link to Crows-foot notation on
Moodle and scroll to the bottom for other
systems.
• Chen notation is the most used
alternative to crows-foot.
• It has the same functionality.

Andy Wicks (c) 2019 26


Source: http://articleexamples.com/10-chen-notation/

Andy Wicks (c) 2019 27


Coursework
• You can use any notation system you like, but it
MUST be used correctly and consistently.
• There is no point in creating the database yet
because you will have to scrap it and start again.
• You will enhance your marks by creating a really
good database design.
• You will enhance your marks by creating a list of
assumptions.
Andy Wicks (c) 2019 28
Getting more marks easily
• One person has completed 11 tasks in 46mins.
• That is about 1/3 of the course.
• They will have got a far better grasp of how to
design a relational database.
• Therefore in ¾ hour they will have increased
their marks and decreased the effort needed
for the coursework.
Andy Wicks (c) 2019 29
Getting more marks easily
• Sign up with LYW4.life and tell me your LYW
number so that I can enrol you.
• Enrol on this course by clicking on Enrol on a
run and then copying/pasting the code on the
web page (wa02-1556-2018/19).
• Click on Open a run and choose the top item,
Designing and implementing Databases.
Andy Wicks (c) 2019 30
Getting more marks easily
• You can now choose a task from the drop-
down and try the quiz as often as you like.
• If you are stuck on a question then go back to
the text (Main Contents) and you will not lose
the answers you have.
• You can use video, audio or PDF if you prefer.
• Please get task quizzes finished.
Andy Wicks (c) 2019 31
Getting more marks easily
• There are other goodies too.
• You can “phone a friend” by using the links to
social media.
• You can link to storage sites, such as your
OneDrive, Google Drive or DropBox accounts.
• Searching and finding resources are also
available to save you time and effort.
Andy Wicks (c) 2019 32
A Problem …
• People have just been tapping in and then
going home.
• This is not a problem that I have had before.
• Therefore, tapping in will only happen at the
end of a tutorial slot for those whose work we
have seen.
• No work – no tap in because you were not in!
Andy Wicks (c) 2019 33
We have covered …
• How to use the six-step process in a complex
situation. Whilst you are unlikely to meet
science fiction at work, you will meet lots of
poor user specifications.
• We looked at strong/weak entities.
• We looked at strong/weak relationships.
• We looked at alternatives to crows-foot.
Andy Wicks (c) 2019 34
In the tutorial …
• Use the quizzes on LYW4 to go over we
covered in the lecture today.
• Join your pair to go into LucidChart and
start re-designing the DB for your
coursework by using the techniques
covered today.
• Do NOT create any SQL!
Andy Wicks (c) 2019 35
Also …
1. There is a list on Moodle of those who have
yet to interact with the pairing survey.
Please see me in the tutorial if you are on
that list.
2. Sign up with LucidChart and LYW4 if you
have not done so yet. You will need these for
your coursework.

Andy Wicks (c) 2019 36


Next Week
• The lecture will be split into two parts again.
• In the first part we will create a DB design for an
art gallery (it is on Moodle already) so you can
start now.
• Then we will look at object orientation when
dealing with databases. This is genuinely more
challenging, so coming to the lecture will feed into
your coursework directly.
Andy Wicks (c) 2019 37
So, …
• … will I see you on time next week?

Andy Wicks (c) 2019 38

You might also like