Saving Data on Android


Rela/ons and en/ty-rela/onship diagrams



Download 19,28 Mb.
Pdf ko'rish
bet136/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   132   133   134   135   136   137   138   139   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

Rela/ons and en/ty-rela/onship diagrams
In this chapter, we are going to create a relation between the 
Question
 entity and 
the 
Answer
 entity that you created in the previous chapter. The only problem is... 
you know... relationships are always hard to understand even if it is just between two 
single tables. Therefore, in this section, we are going to talk about a little tool that 
will help you to better understand the different kinds of relations between tables: 
entity-relationship diagrams
.
You might have heard of entity-relationship diagrams before. They are quite 
common in software design and it's one of the first things they teach in college in 
courses such as 
Databases 101
 or 
Introduction to Relational Databases
. An 
entity-relationship diagram, ER diagram or 
ERD
 is a kind of flowchart that illustrates 
the relationships between the components of a system representing something like a 
school or a company using a set of symbols that include rectangles, ovals and 
connecting lines.
ER diagrams are commonly created during the initial design of a database schema to 
determine the tables, their fields and the nature of the relationship between them.
Many different ERD notations have been created over the years to serve different 
purposes. The notation that we are using in this section is called 
Crow's Foot
 
notation. Although ER diagrams may have different elements depending on the 
notation system, they usually share similar components that include the following:
Saving Data on Android
Chapter 7: Mastering Relations
raywenderlich.com
121


En/ty
Represents a component, object or a concept of a system. Concepts described by an 
entity can be concrete, such as a student or a car, or abstract, such as an event or a 
schedule. Entities are translated as tables when creating your database schema. They 
are commonly illustrated as rectangles in most ER diagrams:
The Student entity
Entities in Crow's Foot notation also include a list of attributes or properties that 
define them. For a user entity, its attributes could be username, password and email.
The User entity
Rela/onship
A relationship tells you how two entities interact with each other and it's usually 
represented as a verb surrounded by a diamond. For example, think about a student 
entity and a class entity. Their relationship could be described as follows:
Relation between entities
Saving Data on Android
Chapter 7: Mastering Relations
raywenderlich.com
122


In this ER diagram, the relationship is described as "takes" and you could read it left 
to right:
A student takes a class
.
Or right to left:
A class is taken by a student.
Note:
 Not all ER diagrams illustrate the relationship between their entities 
since it is often easy to infer from the context. In Crow's Foot notation, it is 
usually omitted.
Cardinality
Last but not least, the cardinality tells you the kind of relationship two entities have. 
There are three main cardinal relationships:
One to one:
 When one entity can only be related to one and only one instance of the 
other entity. For example, a department on a company can only have one head of 
department, and that head of department can only lead one department:
One to One relation
Saving Data on Android
Chapter 7: Mastering Relations
raywenderlich.com
123


One to many:
 When one entity can be related to many instances of another entity. 
For example, a teacher can teach many classes in a single semester, but a class can 
only have one teacher:
One to Many relation
Many to many:
 When many instances of an entity can also be related to many 
instances of another entity. For example, a book (like this one) can have many 
authors, and authors can write many books:
Many to Many relation
Cardinalities can also have constraints that indicate the minimum and maximum 
numbers in the relationships: 
One and only one

zero or one

zero or many
 and 
one or 
many
.
Here is the full list of cardinalities and constraints that you can find:
ER Cardinalities
Saving Data on Android
Chapter 7: Mastering Relations
raywenderlich.com
124


Now that you know how ER diagrams work, you will now learn how to create 
relationships using 

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   132   133   134   135   136   137   138   139   ...   292




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish