Upload
patricia-williamson
View
220
Download
2
Tags:
Embed Size (px)
Citation preview
1
Desing Desing DataDatabase Systemsbase Systems
2
Hierarchy databaseHierarchy database
•The structure of data is like a tree
•Parent-children relationship
•Pointers
Central depot
West depot East depot
Győr Pécs Szeged Debrecen
3
Net database
Dairy collection
Centre
Area of Fót Area of Tata
Kiss János
Nagy Béla
Tóth Elek
The data are connected to each other like a ring, and these rings are the net model. (graph)
4
Relations databaseRelations database YYou use ou use databasesdatabases
to organize and to organize and relate relate tablestables
Databases provide Databases provide the architecture the architecture for storing your for storing your data and have data and have additional benefits additional benefits as well.as well.
More details in More details in the next lecturethe next lecture
5
Goals of the database design Goals of the database design process:process:
understand your data and why you’re tracking itunderstand your data and why you’re tracking it • • eliminate duplication of dataeliminate duplication of data • • eliminate redundant dataeliminate redundant data • • eliminate meaningless data or data we don’t care abouteliminate meaningless data or data we don’t care about • • promote accuracy of datapromote accuracy of data • • promote consistency of datapromote consistency of data • • make sure we can retrieve the information we need from make sure we can retrieve the information we need from
the databasethe database • • support the business functions that use the databasesupport the business functions that use the database • • build a database that lends itself to future growthbuild a database that lends itself to future growth
6
Entity Relationship DiagramsEntity Relationship Diagrams(ERD)(ERD)
What is an ERD?What is an ERD?
An entity-relationship diagram is a An entity-relationship diagram is a data modeling technique that creates a technique that creates a graphical representation of the entities, and graphical representation of the entities, and the relationships between entities, within an the relationships between entities, within an information system. information system.
7
Base Feaures of the ERDBase Feaures of the ERD
Simple, visual, graphical deviceSimple, visual, graphical device The models most important parts are the The models most important parts are the
entitiesentities and the relationships and the relationships It is built from the attributes of the entitiesIt is built from the attributes of the entities
8
EntityEntity
An entity is an object or concept An entity is an object or concept about which you want to store about which you want to store
informationinformation..
9
The common description of the entity is a rectangle, which contains the name of the entity:
Owner Dog
Description of the Entities
10
Type of the EntitiesType of the Entities
EntityAn entity is an object or concept about which you want to store information
Weak EntityA weak entity is dependent on another entity to exist.
11
AttributesAttributes
Attributes are the properties or Attributes are the properties or characteristics of an entity.characteristics of an entity.
12
We can describe the attributes of the entity with a connecting ellipse:
Person
NameDate of birth
Place of birth
Sex
Description of the Attributes
13
Types of the Attributes
AttributesAttributesAttributes are the properties or Attributes are the properties or characteristics of an entity. characteristics of an entity.
Key attributeKey attributeA key attribute is the unique, A key attribute is the unique, distinguishing characteristic of the distinguishing characteristic of the entity. For example, an employee's entity. For example, an employee's social security number might be the social security number might be the employee's key attribute. employee's key attribute.
14
Types of the Attributes A multivalued attribute A multivalued attribute
can have more than one can have more than one value. For example, an value. For example, an employee entity can have employee entity can have multiple skill values. multiple skill values.
Derived attributeDerived attributeA derived attribute is A derived attribute is based on another attribute. based on another attribute. For example, an For example, an employee's monthly salary employee's monthly salary is based on the employee's is based on the employee's annual salary. annual salary.
15
16
RelationshipsRelationships
Relationships illustrate how two Relationships illustrate how two entities share information in the entities share information in the database structure.database structure.
17
We can describe the relationship of the entity with a rhombus. We can mark the type of the relationship as well.
ManDoghas1 N
If an entity takes part in a connection only partly, we describe it with single line, (Not all men have dogs), if it takes part totally we describe it with a bold line.( We don’t respect the stray dogs)
Description of the Relationships
18
Types of the Relationship RelationshipsRelationships
Relationships illustrate Relationships illustrate how two entities share how two entities share information in the information in the database structure.database structure.
Weak relationshipWeak relationshipTo connect a weak To connect a weak entity with others, you entity with others, you should use a weak should use a weak relationship notation. relationship notation.
19
Cardinality
Cardinality specifies how many instances of an entity relate to one instance of another entity.
20
CardinalityCardinality
»1:11:1 (wife-husband)(wife-husband)
»1: N1: N (mother-children)(mother-children)
»N:MN:M (grandparents-grandchildren)(grandparents-grandchildren)
21
Examples - Relationship
1 Department may employ Many Employees1 Employee only has one department
Department EmployeesEmploys
1 N
The diagram changes according to your real situation.
Department EmployeesEmploys
M N
You may also allow 1 Employee to work for Many Departments
22
ParticipationParticipation
»Total participationTotal participationEvery child has a motherEvery child has a mother
»Partial participationPartial participationNot every woman has a childNot every woman has a child
23
Example - Participation
Every department must have at least one employee.An employee need not work for any department.Indicate partial participation by using
Department EmployeesEmploys
1 N
24
Recursive Recursive relationshiprelationshipIn some cases, entities In some cases, entities can be self-linked. For can be self-linked. For example, employees example, employees can supervise other can supervise other employees. employees.
25
Students Courses
ID LName FNameAddress
CNum CName Description
Relationship
Take
Entity
Entity
Attributes
Attributes
26
Simplified car selling model
Car
Type
Years
Price
buy1
Customer
Address
Name
Driving licence
N
27
DataData
Name Address Dlicense Type Year PriceKiss J. 1012 Ló 1 xy-1231 Trabant 500 36 5000Jó Ede 1042 Tó 1 wq-2345 Lada 1200 20 50000Kiss J. 1012 Ló 1 xy-1231 Fiat 600 18 40000Nagy G 1033 Kő 2 ww-1122 Kia 606 10 120000
Problems: - don’t give back the relationships- repeating data…
We have to study….
28
buy1
Car
Type
Years
N
Price
sell1
Extension of the modelExtension of the model
Customer
Name
Address
Selling
Customer
Car
N
DateDriving licence