SlideShare une entreprise Scribd logo
1  sur  6
Lecture 2 - Relational Model
1
Fall 2001 Database Systems 1
Relational Model
• In the relational data model
– a database is a set of tables (with additional constraints,
programs and interfaces)
– a schema is the description of tables in a database
– a relation or a table is a “set” of tuples
– a tuple or a record is a mapping from a set of attributes to their
values
– an attribute is a slot for recording data, it has a name and a
domain of applicable values
– the schema of a table contains the table’s name and the
attributes and the domain of the attributes
Fall 2001 Database Systems 2
Example Database - Auction
• OWNERS - people who sell items
– Oid unique identifier given to them
– Name their name
– Email their e-mail address
• ITEMS - the items sold by “owners”
– Iid unique identifier of an item being sold
– Oid the owner of the item
– Name description of the item
– Location location of the item
• BUYERS - registered buyers allowed to bid on items
– Buyid buyer identifier
– Name buyer’s name
– Email buyer’s e-mail address
Lecture 2 - Relational Model
2
Fall 2001 Database Systems 3
Example Database - Auction
• BIDS - people place bids on a specific item of a
specific owner
– Bid unique identifier of a bid
– Date the date it was put online
– Iid which item
– Oid who owns the item
– Buyid who placed the bid
– Amount how much is the buyer bidding
• Additional logic:
– BIDS and ITEMS contain all the “unsold” items.
As soon as an item is sold, it is deleted from
bids and items. The loosing bidders are notified
that they lost the item.
Fall 2001 Database Systems 4
 ¢¡¤£¦¥¨§¨©   £ ¥ ! 
#%$ (') 021 Smith@aol.com
#¦3 4657198A@ Johns@geocities.com
#B C9DE5GF8 Brown@netmail.com
#IH PQDERTS Gray@microsoft.com
UVXW(Y`¨a U9bTcde f¢gihqp Y¨hqg!d r
sut vXwExAy Gray@microsoft,com
€¨ ‚9ƒ„7…9†ˆ‡2‰ Robert432@aol.com
€9 ‘uƒi’“”‰ Johns@somewhere.co
m
€7• ‘¨–7‰Aƒ“ Jj@yahoo.com
€9— ˜Q™edA… Duke@jazz.com
fegih¨jk f!lm nlm oqpqir setTuGpevGltew
x9y z¦y {I|E}e~e€A
‚GƒT„ …
†i‡TˆA}”‡|
x9‰ z¦‰ Š6‹iƒeŒTeˆT…Geƒeˆ
Ž ‡G„ …i7}2‘“’
”i‡e€AˆA}E‡!|
x• z¦‰ Š6‹iƒeŒTeˆT…Geƒeˆ
Ž ‡G„ …i7}2‘“’
–qe—
˜u‡e2Œ
™7š ›¢œ !žeŸE A¡7¢E¢2¡ £6¤i¥ ¥¤G¦
™§ ›qš ¨¨¤e©e©ª7«
!ži¥ ¥¡i¬A¢T­ž®
¯ ¡7¤T¢”¢e¥¡
™i° ›¦± !žeŸE A¡7¢E¢2¡ ²ižT¦A¢”ž®
³9´9µQ¶ ³u·¸ µX¹iº2» ´!· ¸ ¼¦· ¸ ³9½T¾!´i¸ ¿ÀqÁ7½7ÂGº
ÃuÄ ÅuÆ Ç9È7É9Ê Ë!Æ Ì¦Æ ÃuÍ ÆÎʨÊ
ÃuÄ ÅuÍ Ç9È7É9Ê ËeÏ ÌÉ Ã¨Ð É9ʨÊ9ʨÊ
ÃuÄ Å¨É Ç9È7ÉuÆ Ë!Æ Ì¦Æ ÃuÍ Æ”Í!Ê
ÃuÄ Å!Ï Ñ9ÈiÆ ËiÒ ÌÉ Ã¨Ð ÍÏuÊ9ʨÊ
ÃuÄ Å¨Ð Ñ9ÈiÆ Ë!Æ Ì¦Æ ÃuÍ Æ”Í¨Æ
ÃuÄ ÅÒ Ñ9ÈiÍ ËeÏ ÌÉ Ã!Ï É¨Ð9Ê9ʨÊ
ÃuÄ Å9Ó Ñ9ÈiÍ Ë!Í Ì¦Í ÃuÆ ÍÐ9Ê
ÃuÄ ÅÇ Ñ9È7É Ë!Í Ì¦Í Ã¨É Í!ʨÊ
Lecture 2 - Relational Model
3
Fall 2001 Database Systems 5
Attributes and Domains
• Let D1 = the letter “O” followed by the set of all
integers
D2 = the set of all strings up to 30 characters
that contain only letters A-Z,a-z
D3 = the set of all strings that contain a single
@ symbol, and a combination of
Alphanumeric characters and “.”.
Then, owners relation has schema
Owners(OID:D1, Name:D2, Email:D3)
Fall 2001 Database Systems 6
Attributes - Domains
• All tuples in Owners come from
– D1 × D2 × D3
– An example tuple: OID:O1, Name: ’Smith’,
Email: ‘smith@aol.com’
– For any tuple: OID:v1, Name: v2, Email: v3
we have the property that v1 ∈ D1, v2 ∈ D2, v3 ∈ D3
• We usually abuse notation and assume an ordering
for the attribute/domain pairs, and write the relation
schema as:
Owners(OID, Name, Email)
and a tuple as:
O1,’Smith’,’smith@aol.com ∈ Owners
Lecture 2 - Relational Model
4
Fall 2001 Database Systems 7
More on domains
• A domain is a type in the programming language sense
• Domain values is a set of acceptable values for a
variable of a given type.
– Zipcode: zipcodeDomain = {11111, … ,99999},
– Grants: availableGrants = {50,000, … ,1,000,000}
– Simple/Composite domains
• Address = Street name+street number+city+province+ postal code
• Domain compatibility
– Binary operations (e.g., comparison to one another, addition, etc)
can be performed on them.
• Full support for domains is not provided in many current
relational DBMSs
Fall 2001 Database Systems 8
Relation Instances
• A relation/table instance is a set of tuples with a
specific schema (attribute/domain pairs)
List form:
OWNERS(OID,Name,Email) = { O1, Smith, smith@aol.com,
O2, Johns, johns@geocities.com, O3, Brown,
Brown@netmail.com, O4, Gray, Gray@microsoft.com }
Tabular form: Ô Õ¤Ö¦×uب٠ÔÚ Û ÖÜiÝIÞ ×¨ÝqÜ!Ú ß
à%á âäã¦åæAç Smith@aol.com
à¦è é6êeç9ëTì Johns@geocities.com
àí î!ïEêeðië Brown@netmail.com
àIñ òQïEóAô Gray@microsoft.com
Lecture 2 - Relational Model
5
Fall 2001 Database Systems 9
Relational Model
Based on finite set theory:
• First Normal Form Rule: all attributes take simple
values - no set values are allowed.
• Rows are accessed only by their content. The order of
tuples does not have any meaning.
• The order of columns does not have any specific
meaning either.
• No two tuples can have the same values for all the
attributes, i.e. relations are sets.
• Commercial systems allow duplicates (so bag
semantics)
Fall 2001 Database Systems 10
Keys
• A superkey is a set of attributes that help uniquely
identify a specific tuple
– if no two owners may have the same Oid, then Oid
is a superkey
– if no two owners may have the same email
address, then Email is a superkey
• How about:
– Oid + Name (together) for Owners?
– Oid + Name (together) for ITEMS?
– Iid + Oid (together) for ITEMS?
Lecture 2 - Relational Model
6
Fall 2001 Database Systems 11
Keys
• Given relation T, we use t[A1,…,Ak] to denote tuples with only
attributes A1,…,Ak
– for example, if t = O1, Smith, smith@aol.com then
t[oid,name] = O1, Smith
• Given a relation T with attributes {A1,…,Ak}, a key is a set of
attributes {B1,…,Bm} ⊆ {A1,…,Ak} such that
– if u and v are distinct tuples in relation T, then u[B1,…,Bm] and
v[B1,…,Bm] are necessarily different from each other by user
design!
– no proper subset of {B1,…,Bm} has this property
• Every table must have a unique primary key
– Primary key is a key designated by the user and managed by
the system
Fall 2001 Database Systems 12
Null values
• Attributes may be allowed to have null values because
– a value does not exist for a tuple
– a value exists, but it is not known
– it is not known whether a value exists or not
• Integrity rule: No column in a primary key can have null
values

Contenu connexe

Tendances

Sql practise for beginners
Sql practise for beginnersSql practise for beginners
Sql practise for beginners
ISsoft
 
MS SQL Server 1
MS SQL Server 1MS SQL Server 1
MS SQL Server 1
Iblesoft
 

Tendances (20)

Sql for biggner
Sql for biggnerSql for biggner
Sql for biggner
 
Ankit
AnkitAnkit
Ankit
 
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQLSql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
 
Sql
SqlSql
Sql
 
Sql practise for beginners
Sql practise for beginnersSql practise for beginners
Sql practise for beginners
 
Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginners
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
BIS05 Introduction to SQL
BIS05 Introduction to SQLBIS05 Introduction to SQL
BIS05 Introduction to SQL
 
SQL Language
SQL LanguageSQL Language
SQL Language
 
Learning sql from w3schools
Learning sql from w3schoolsLearning sql from w3schools
Learning sql from w3schools
 
SQL
SQLSQL
SQL
 
Advanced SQL Webinar
Advanced SQL WebinarAdvanced SQL Webinar
Advanced SQL Webinar
 
Sql slid
Sql slidSql slid
Sql slid
 
MS SQL Server 1
MS SQL Server 1MS SQL Server 1
MS SQL Server 1
 
SQL (Basic to Intermediate Customized 8 Hours)
SQL (Basic to Intermediate Customized 8 Hours)SQL (Basic to Intermediate Customized 8 Hours)
SQL (Basic to Intermediate Customized 8 Hours)
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 

Similaire à [Www.pkbulk.blogspot.com]dbms02

Similaire à [Www.pkbulk.blogspot.com]dbms02 (20)

Databases for beginners.pdf
Databases for beginners.pdfDatabases for beginners.pdf
Databases for beginners.pdf
 
15 wordprocessing ml subject - fields and hyperlinks
15   wordprocessing ml subject - fields and hyperlinks15   wordprocessing ml subject - fields and hyperlinks
15 wordprocessing ml subject - fields and hyperlinks
 
Basics R.ppt
Basics R.pptBasics R.ppt
Basics R.ppt
 
Basics.ppt
Basics.pptBasics.ppt
Basics.ppt
 
[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03
 
603s129
603s129603s129
603s129
 
Apl – a programming language
Apl – a programming languageApl – a programming language
Apl – a programming language
 
PhillyR 18-19 Kickoff - Data Structure Intro
PhillyR 18-19 Kickoff - Data Structure IntroPhillyR 18-19 Kickoff - Data Structure Intro
PhillyR 18-19 Kickoff - Data Structure Intro
 
lec02-data-models-sql-basics.pptx
lec02-data-models-sql-basics.pptxlec02-data-models-sql-basics.pptx
lec02-data-models-sql-basics.pptx
 
04 pig data operations
04 pig data operations04 pig data operations
04 pig data operations
 
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH) Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
 
So MANY databases, which one do I pick?
So MANY databases, which one do I pick?So MANY databases, which one do I pick?
So MANY databases, which one do I pick?
 
23xml
23xml23xml
23xml
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
DB2 on Mainframe
DB2 on MainframeDB2 on Mainframe
DB2 on Mainframe
 
Xmll
XmllXmll
Xmll
 
Xml
XmlXml
Xml
 
Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)
 
Relational Model on Database management PPT
Relational Model on Database management PPTRelational Model on Database management PPT
Relational Model on Database management PPT
 
Xml basics concepts
Xml basics conceptsXml basics concepts
Xml basics concepts
 

Plus de AnusAhmad

Plus de AnusAhmad (19)

[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing
 
[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12
 
[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11
 
[Www.pkbulk.blogspot.com]dbms10
[Www.pkbulk.blogspot.com]dbms10[Www.pkbulk.blogspot.com]dbms10
[Www.pkbulk.blogspot.com]dbms10
 
[Www.pkbulk.blogspot.com]dbms09
[Www.pkbulk.blogspot.com]dbms09[Www.pkbulk.blogspot.com]dbms09
[Www.pkbulk.blogspot.com]dbms09
 
[Www.pkbulk.blogspot.com]dbms07
[Www.pkbulk.blogspot.com]dbms07[Www.pkbulk.blogspot.com]dbms07
[Www.pkbulk.blogspot.com]dbms07
 
[Www.pkbulk.blogspot.com]dbms06
[Www.pkbulk.blogspot.com]dbms06[Www.pkbulk.blogspot.com]dbms06
[Www.pkbulk.blogspot.com]dbms06
 
[Www.pkbulk.blogspot.com]dbms04
[Www.pkbulk.blogspot.com]dbms04[Www.pkbulk.blogspot.com]dbms04
[Www.pkbulk.blogspot.com]dbms04
 
[Www.pkbulk.blogspot.com]dbms01
[Www.pkbulk.blogspot.com]dbms01[Www.pkbulk.blogspot.com]dbms01
[Www.pkbulk.blogspot.com]dbms01
 
[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13
 
9. java server faces
9. java server faces9. java server faces
9. java server faces
 
8. java script
8. java script8. java script
8. java script
 
7. struts
7. struts7. struts
7. struts
 
5. servlets
5. servlets5. servlets
5. servlets
 
4. jsp
4. jsp4. jsp
4. jsp
 
3. applets
3. applets3. applets
3. applets
 
2. http, html
2. http, html2. http, html
2. http, html
 
1. intro
1. intro1. intro
1. intro
 
6. hibernate
6. hibernate6. hibernate
6. hibernate
 

Dernier

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 

Dernier (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

[Www.pkbulk.blogspot.com]dbms02

  • 1. Lecture 2 - Relational Model 1 Fall 2001 Database Systems 1 Relational Model • In the relational data model – a database is a set of tables (with additional constraints, programs and interfaces) – a schema is the description of tables in a database – a relation or a table is a “set” of tuples – a tuple or a record is a mapping from a set of attributes to their values – an attribute is a slot for recording data, it has a name and a domain of applicable values – the schema of a table contains the table’s name and the attributes and the domain of the attributes Fall 2001 Database Systems 2 Example Database - Auction • OWNERS - people who sell items – Oid unique identifier given to them – Name their name – Email their e-mail address • ITEMS - the items sold by “owners” – Iid unique identifier of an item being sold – Oid the owner of the item – Name description of the item – Location location of the item • BUYERS - registered buyers allowed to bid on items – Buyid buyer identifier – Name buyer’s name – Email buyer’s e-mail address
  • 2. Lecture 2 - Relational Model 2 Fall 2001 Database Systems 3 Example Database - Auction • BIDS - people place bids on a specific item of a specific owner – Bid unique identifier of a bid – Date the date it was put online – Iid which item – Oid who owns the item – Buyid who placed the bid – Amount how much is the buyer bidding • Additional logic: – BIDS and ITEMS contain all the “unsold” items. As soon as an item is sold, it is deleted from bids and items. The loosing bidders are notified that they lost the item. Fall 2001 Database Systems 4  ¢¡¤£¦¥¨§¨©   £ ¥ ! #%$ (') 021 Smith@aol.com #¦3 4657198A@ Johns@geocities.com #B C9DE5GF8 Brown@netmail.com #IH PQDERTS Gray@microsoft.com UVXW(Y`¨a U9bTcde f¢gihqp Y¨hqg!d r sut vXwExAy Gray@microsoft,com €¨ ‚9ƒ„7…9†ˆ‡2‰ Robert432@aol.com €9 ‘uƒi’“”‰ Johns@somewhere.co m €7• ‘¨–7‰Aƒ“ Jj@yahoo.com €9— ˜Q™edA… Duke@jazz.com fegih¨jk f!lm nlm oqpqir setTuGpevGltew x9y z¦y {I|E}e~e€A ‚GƒT„ … †i‡TˆA}”‡| x9‰ z¦‰ Š6‹iƒeŒTeˆT…Geƒeˆ Ž ‡G„ …i7}2‘“’ ”i‡e€AˆA}E‡!| x• z¦‰ Š6‹iƒeŒTeˆT…Geƒeˆ Ž ‡G„ …i7}2‘“’ –qe— ˜u‡e2Œ ™7š ›¢œ !žeŸE A¡7¢E¢2¡ £6¤i¥ ¥¤G¦ ™§ ›qš ¨¨¤e©e©ª7« !ži¥ ¥¡i¬A¢T­ž® ¯ ¡7¤T¢”¢e¥¡ ™i° ›¦± !žeŸE A¡7¢E¢2¡ ²ižT¦A¢”ž® ³9´9µQ¶ ³u·¸ µX¹iº2» ´!· ¸ ¼¦· ¸ ³9½T¾!´i¸ ¿ÀqÁ7½7ÂGº ÃuÄ ÅuÆ Ç9È7É9Ê Ë!Æ Ì¦Æ ÃuÍ ÆÎÊ¨Ê ÃuÄ ÅuÍ Ç9È7É9Ê ËeÏ ÌÉ Ã¨Ð É9ʨÊ9Ê¨Ê ÃuÄ Å¨É Ç9È7ÉuÆ Ë!Æ Ì¦Æ ÃuÍ Æ”Í!Ê ÃuÄ Å!Ï Ñ9ÈiÆ ËiÒ ÌÉ Ã¨Ð ÍÏuÊ9Ê¨Ê ÃuÄ Å¨Ð Ñ9ÈiÆ Ë!Æ Ì¦Æ ÃuÍ Æ”Í¨Æ ÃuÄ ÅÒ Ñ9ÈiÍ ËeÏ ÌÉ Ã!Ï É¨Ð9Ê9Ê¨Ê ÃuÄ Å9Ó Ñ9ÈiÍ Ë!Í Ì¦Í ÃuÆ ÍÐ9Ê ÃuÄ ÅÇ Ñ9È7É Ë!Í Ì¦Í Ã¨É Í!ʨÊ
  • 3. Lecture 2 - Relational Model 3 Fall 2001 Database Systems 5 Attributes and Domains • Let D1 = the letter “O” followed by the set of all integers D2 = the set of all strings up to 30 characters that contain only letters A-Z,a-z D3 = the set of all strings that contain a single @ symbol, and a combination of Alphanumeric characters and “.”. Then, owners relation has schema Owners(OID:D1, Name:D2, Email:D3) Fall 2001 Database Systems 6 Attributes - Domains • All tuples in Owners come from – D1 × D2 × D3 – An example tuple: OID:O1, Name: ’Smith’, Email: ‘smith@aol.com’ – For any tuple: OID:v1, Name: v2, Email: v3 we have the property that v1 ∈ D1, v2 ∈ D2, v3 ∈ D3 • We usually abuse notation and assume an ordering for the attribute/domain pairs, and write the relation schema as: Owners(OID, Name, Email) and a tuple as: O1,’Smith’,’smith@aol.com ∈ Owners
  • 4. Lecture 2 - Relational Model 4 Fall 2001 Database Systems 7 More on domains • A domain is a type in the programming language sense • Domain values is a set of acceptable values for a variable of a given type. – Zipcode: zipcodeDomain = {11111, … ,99999}, – Grants: availableGrants = {50,000, … ,1,000,000} – Simple/Composite domains • Address = Street name+street number+city+province+ postal code • Domain compatibility – Binary operations (e.g., comparison to one another, addition, etc) can be performed on them. • Full support for domains is not provided in many current relational DBMSs Fall 2001 Database Systems 8 Relation Instances • A relation/table instance is a set of tuples with a specific schema (attribute/domain pairs) List form: OWNERS(OID,Name,Email) = { O1, Smith, smith@aol.com, O2, Johns, johns@geocities.com, O3, Brown, Brown@netmail.com, O4, Gray, Gray@microsoft.com } Tabular form: Ô Õ¤Ö¦×uب٠ÔÚ Û ÖÜiÝIÞ ×¨ÝqÜ!Ú ß à%á âäã¦åæAç Smith@aol.com à¦è é6êeç9ëTì Johns@geocities.com àí î!ïEêeðië Brown@netmail.com àIñ òQïEóAô Gray@microsoft.com
  • 5. Lecture 2 - Relational Model 5 Fall 2001 Database Systems 9 Relational Model Based on finite set theory: • First Normal Form Rule: all attributes take simple values - no set values are allowed. • Rows are accessed only by their content. The order of tuples does not have any meaning. • The order of columns does not have any specific meaning either. • No two tuples can have the same values for all the attributes, i.e. relations are sets. • Commercial systems allow duplicates (so bag semantics) Fall 2001 Database Systems 10 Keys • A superkey is a set of attributes that help uniquely identify a specific tuple – if no two owners may have the same Oid, then Oid is a superkey – if no two owners may have the same email address, then Email is a superkey • How about: – Oid + Name (together) for Owners? – Oid + Name (together) for ITEMS? – Iid + Oid (together) for ITEMS?
  • 6. Lecture 2 - Relational Model 6 Fall 2001 Database Systems 11 Keys • Given relation T, we use t[A1,…,Ak] to denote tuples with only attributes A1,…,Ak – for example, if t = O1, Smith, smith@aol.com then t[oid,name] = O1, Smith • Given a relation T with attributes {A1,…,Ak}, a key is a set of attributes {B1,…,Bm} ⊆ {A1,…,Ak} such that – if u and v are distinct tuples in relation T, then u[B1,…,Bm] and v[B1,…,Bm] are necessarily different from each other by user design! – no proper subset of {B1,…,Bm} has this property • Every table must have a unique primary key – Primary key is a key designated by the user and managed by the system Fall 2001 Database Systems 12 Null values • Attributes may be allowed to have null values because – a value does not exist for a tuple – a value exists, but it is not known – it is not known whether a value exists or not • Integrity rule: No column in a primary key can have null values