Database System
Chapter No. 03: Entity Relationship Model
Lecture - 05
Attributes
2
 Attribute - property or characteristic of an entity type
 Classificationsof attributes:
• Simple VsComposite Attribute
• Single-V
alued VsMultivalued Attribute
• Stored VsDerived Attributes
• IdentifierAttributes
Attribute Domain
 Anattributedomainisasetofpossiblevaluesfor anattribute.
 Thedomainmayconsistofarangeofvaluesor somediscrete
values.
 Example:domainforGPA(attribute)canbefrom0 to4.
 E.g.Thedomainforgenderattributecanbeeither femaleor
male.
3
Different TypesOf Attributes
4
 An attribute can take its valuesfroma set of possible values
for eachentity instance in an ERmodelin DBMS.
Simple attribute
5
Simple attributes in an ERmodel diagram are independent
attributes that can't be classified further and also, can't be
subdivided into any other component.Theseattributes are also
known as atomic attributes.
Composite Attribute
6
Composite attributes have opposite functionality to that of simple
attributes as we can further subdivide composite attributes into
different components or sub-parts that form simple attributes. In
simple terms, composite attributes are composed of one or more
simple attributes.
Single-Valued Attributes
7
Single valued attributes are those attributes that consist of a single value
for each entity instance and can't store more than one value. Thevalue of
these single-valued attributes always remains the same, just like the name
of a person.
Multi-Valued Attributes
8
Multi-valued attributes have opposite functionality to that of single-
valued attributes, and as the name suggests, multi-valued attributes can
take up and store more than one value at a time for an entity instance
from a set of possible values. These attributes are represented by co-
centric elliptical shape.
Derived Attributes
9
Derived attributes are those attributes whose values can be derived from
the values of other attributes. They are always dependent upon other
attributes for their value.
Key Attributes
11
Key attributes are special types of attributes that act as the primary
key for an entity and they can uniquely identify an entity from an
entity set. The values that key attributes store must be unique and non-
repeating.
Identifiers (Keys)
 Identifier (Key)
An attribute (or combination of attributes) that uniquely
identifies individual instancesof an entity type
 Simple Key versus Composite Key
12
An identifier that consists of only one
attribute.
Example:
the identifier for STUDENT entity
type is Student_ID
An identifier that consist of composite
attributes
Example:
OrderID maybe consists of orderNo &
Date
Simple key attribute
14
The key isunderlined
Relationships
 One to one
Example: Country ----president
 One to many
Example: State ---- city
Example: University-----departments
 Many to many
Example: Students -------courses
13
T
ypes of Keys in DBMS
15
 Super Key
 Candidate Key
 Primary Key
 Alternate Key
 Foreign Key
 Composite Key
Super Key
 Super Keyisthe setof all the keyswhichhelp to identify rows
ina table uniquely.
 This means that all those columns of a table than capable of
identifying the other columnsof that table uniquely will all be
considered super keys.
 Super Key is the superset of a candidate key (explained
below).The Primary Key of a table ispicked fromthe super
key set to be made the table’s identity attribute.
16
Candidate Key
 Candidate keys are those attributes that uniquely identify rows of
a table.
 ThePrimary Keyof a table isselectedfrom oneof thecandidate
keys.So,candidate keyshavethesameproperties astheprimary keys
explained above.There can be morethanone candidate keys ina
table.
 There can be more candidate keys than just one for any table, but
they can never be empty.
 Every candidate key carries unique information and value. Besides
thesecharacteristics, a combination of attributes alsoworks as a set
of candidate keys.
17
Primary Key
 Primary keyisa columnof a table or a setof columnsthat helpsto
identify every record present in that table uniquely.
 There can be only one primary Key in a table. Also, the primary
Key cannot have the same values repeating for any row.
 Every value of the primary key must be different with no repetitions.
A primary keyisthemostsignificant oneto understand what are keys
and what is primary key in DBMS.
 ThePRIMARYKEY(PK) constraint put on a column or set of columns
will not allow them to have any null values or any duplicates. One
table can have only one primary key constraint.
 Any value in the primary key cannot be changed by any foreign
keys (explained below) which refer to it.
18
Alternate Key
 Atable can have multiple choices for a primary key;
however, it canchooseonly one.
 So,all the keys which did not become the primary Keyare
called alternate keys.
19
Foreign Key
 ForeignKeyis used to establishrelationshipsbetween two
tables.Aforeign key will require each value in a columnor
set of columnsto match the Primary Key of thereferential
table.
 Foreign keys help to maintain data and referential
integrity.
 Foreign keys are essential for maintaining a difference
between two entities that might be linked with the same
informationbut do not share similar information.
20
Foreign Key
 Insuchcases, the tablesare linked to maintaining a connection
but do not entirely work as a replacement for each other.
 Forinstance,any individual working for themarketing
department might have marketing department informationinits
employee table, but that doesnot meanthe table canbe similar
to thedepartment table held by the marketing department.
21
Composite Key
 Acomposite Key is a set of two or more attributes that help
identify each tuple in a table uniquely.
 The attributesinthe set may not be unique when
considered separately.
 However, when takenall together, they will ensure
uniqueness.The‘concatenated key’is another name for a
composite key.
22
Composite key attribute
23
The key iscomposed
of two subparts

Understanding Entity Relationship Models

  • 1.
    Database System Chapter No.03: Entity Relationship Model Lecture - 05
  • 2.
    Attributes 2  Attribute -property or characteristic of an entity type  Classificationsof attributes: • Simple VsComposite Attribute • Single-V alued VsMultivalued Attribute • Stored VsDerived Attributes • IdentifierAttributes
  • 3.
    Attribute Domain  Anattributedomainisasetofpossiblevaluesforanattribute.  Thedomainmayconsistofarangeofvaluesor somediscrete values.  Example:domainforGPA(attribute)canbefrom0 to4.  E.g.Thedomainforgenderattributecanbeeither femaleor male. 3
  • 4.
    Different TypesOf Attributes 4 An attribute can take its valuesfroma set of possible values for eachentity instance in an ERmodelin DBMS.
  • 5.
    Simple attribute 5 Simple attributesin an ERmodel diagram are independent attributes that can't be classified further and also, can't be subdivided into any other component.Theseattributes are also known as atomic attributes.
  • 6.
    Composite Attribute 6 Composite attributeshave opposite functionality to that of simple attributes as we can further subdivide composite attributes into different components or sub-parts that form simple attributes. In simple terms, composite attributes are composed of one or more simple attributes.
  • 7.
    Single-Valued Attributes 7 Single valuedattributes are those attributes that consist of a single value for each entity instance and can't store more than one value. Thevalue of these single-valued attributes always remains the same, just like the name of a person.
  • 8.
    Multi-Valued Attributes 8 Multi-valued attributeshave opposite functionality to that of single- valued attributes, and as the name suggests, multi-valued attributes can take up and store more than one value at a time for an entity instance from a set of possible values. These attributes are represented by co- centric elliptical shape.
  • 9.
    Derived Attributes 9 Derived attributesare those attributes whose values can be derived from the values of other attributes. They are always dependent upon other attributes for their value.
  • 10.
    Key Attributes 11 Key attributesare special types of attributes that act as the primary key for an entity and they can uniquely identify an entity from an entity set. The values that key attributes store must be unique and non- repeating.
  • 11.
    Identifiers (Keys)  Identifier(Key) An attribute (or combination of attributes) that uniquely identifies individual instancesof an entity type  Simple Key versus Composite Key 12 An identifier that consists of only one attribute. Example: the identifier for STUDENT entity type is Student_ID An identifier that consist of composite attributes Example: OrderID maybe consists of orderNo & Date
  • 12.
  • 13.
    Relationships  One toone Example: Country ----president  One to many Example: State ---- city Example: University-----departments  Many to many Example: Students -------courses 13
  • 14.
    T ypes of Keysin DBMS 15  Super Key  Candidate Key  Primary Key  Alternate Key  Foreign Key  Composite Key
  • 15.
    Super Key  SuperKeyisthe setof all the keyswhichhelp to identify rows ina table uniquely.  This means that all those columns of a table than capable of identifying the other columnsof that table uniquely will all be considered super keys.  Super Key is the superset of a candidate key (explained below).The Primary Key of a table ispicked fromthe super key set to be made the table’s identity attribute. 16
  • 16.
    Candidate Key  Candidatekeys are those attributes that uniquely identify rows of a table.  ThePrimary Keyof a table isselectedfrom oneof thecandidate keys.So,candidate keyshavethesameproperties astheprimary keys explained above.There can be morethanone candidate keys ina table.  There can be more candidate keys than just one for any table, but they can never be empty.  Every candidate key carries unique information and value. Besides thesecharacteristics, a combination of attributes alsoworks as a set of candidate keys. 17
  • 17.
    Primary Key  Primarykeyisa columnof a table or a setof columnsthat helpsto identify every record present in that table uniquely.  There can be only one primary Key in a table. Also, the primary Key cannot have the same values repeating for any row.  Every value of the primary key must be different with no repetitions. A primary keyisthemostsignificant oneto understand what are keys and what is primary key in DBMS.  ThePRIMARYKEY(PK) constraint put on a column or set of columns will not allow them to have any null values or any duplicates. One table can have only one primary key constraint.  Any value in the primary key cannot be changed by any foreign keys (explained below) which refer to it. 18
  • 18.
    Alternate Key  Atablecan have multiple choices for a primary key; however, it canchooseonly one.  So,all the keys which did not become the primary Keyare called alternate keys. 19
  • 19.
    Foreign Key  ForeignKeyisused to establishrelationshipsbetween two tables.Aforeign key will require each value in a columnor set of columnsto match the Primary Key of thereferential table.  Foreign keys help to maintain data and referential integrity.  Foreign keys are essential for maintaining a difference between two entities that might be linked with the same informationbut do not share similar information. 20
  • 20.
    Foreign Key  Insuchcases,the tablesare linked to maintaining a connection but do not entirely work as a replacement for each other.  Forinstance,any individual working for themarketing department might have marketing department informationinits employee table, but that doesnot meanthe table canbe similar to thedepartment table held by the marketing department. 21
  • 21.
    Composite Key  AcompositeKey is a set of two or more attributes that help identify each tuple in a table uniquely.  The attributesinthe set may not be unique when considered separately.  However, when takenall together, they will ensure uniqueness.The‘concatenated key’is another name for a composite key. 22
  • 22.
    Composite key attribute 23 Thekey iscomposed of two subparts

Editor's Notes

  • #9 Skills,
  • #10 Balance, profit, average sale , discount percentage, net worth
  • #12 An identifier that consists of only one attribute. E.g. the identifier for STUDENT entity type is Student_ID . Composite key (consists of composite attributes ) e.g… orderID maybe consists of orderNO & Date.
  • #16 employee_id email employee_id and email first_name and last_name first_name, last_name, and email Note that in this example, each of the above combinations uniquely identifies each row in the table. However, there may be other combinations of columns that are not unique, such as using only the first name column or only the last name column. These combinations would not be considered super keys.
  • #17 a super key that includes only the attributes that are necessary for uniqueness.
  • #22 order_id and customer_id order_id and product_id customer_id and product_id