Asset Pricing Zheng Zhenlong Chapter 5. Mean-variance frontier and beta representations.
The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.
-
Upload
arianna-jensen -
Category
Documents
-
view
217 -
download
0
Transcript of The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.
![Page 1: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/1.jpg)
The Relational Model
DB Chapter 2 (and some from chapter 4, 5)
J.G. ZhengJune 27th 2005
![Page 2: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/2.jpg)
Overview
Relational model terminologies and foundations
Some design concepts
![Page 3: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/3.jpg)
Introduction
Edgar F. Codd, 1970
One sentence to explain relational database model:
Data are organized in relations (tables),which are linked (relationship) by keys
![Page 4: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/4.jpg)
Relation
A relation is a two-dimensional table that has specific characteristics: The table consist of rows and columns Rows contain data about an entity instances All values in a row describes the same
entity instance Columns contain data about attributes of
the entity All values in a column are of the same kind
![Page 5: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/5.jpg)
Relation (continued)
Relation’s specific characteristics go on: Cells of the table hold a single value Each row is distinct Each column has a unique name The order of the rows is unimportant The order of the columns is
unimportant
![Page 6: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/6.jpg)
Non-Relation Examples
![Page 7: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/7.jpg)
Relation Examples
And, any tables in page 92 and 93
![Page 8: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/8.jpg)
Relation Terminology Contrast
Table Row Column
*Entity Record Field
Relation [Tuple] Attribute
![Page 9: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/9.jpg)
Keys
A key is one or more columns of a relation that is used to identify a record Primary key Foreign key
![Page 10: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/10.jpg)
Primary Key
Primary key The value of this key column uniquely
identifies a single record (row) There is only one primary key for a table
Candidate Key A candidate to become the primary key There can be multiple candidate keys for a
table
Alternate key
![Page 11: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/11.jpg)
Composite Key
A key that contains two or more attributes (columns)
Example “FirstName” + “LastName” “FirstName” + “LastName” + “BirthDate” “FirstName” + “LastName” + “BirthDate” +
“BirthCity” …
![Page 12: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/12.jpg)
Surrogate Key/Artificial Key
It’s a key created arbitrarily to replace the natural key Typically used in place of a composite key Usually it has no real meaning
Example We can create a “ReviewID” in the
“BookReviews” table to replace the original composite key
![Page 13: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/13.jpg)
Relationship and Foreign Key
Relationship defines how tables (relations) are linked
Two tables are linked by a pair of keys The primary key of one table The foreign key in the linked table These two keys are of the same kind
![Page 14: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/14.jpg)
Relationship Example
Primary Key (PK)
Primary Key (PK) Foreign Key
![Page 15: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/15.jpg)
Relationship Types
One-to-one Example: students and GSU network
accounts
One-to-many Example: students and diplomas
*Many-to-many Example: students and professors
![Page 16: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/16.jpg)
Referential Integrity
Every value of a foreign key must match a value of the primary key
For example (“Premiere Products” database) In “Customer” table, “RepNum” is a foreign
key (linked to the “Rep” table where “RepNum” is the primary key).
Then every value of “RepNum” in the “Customer” table must exist in the “Rep” table
![Page 17: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/17.jpg)
Relational Algebra
SelectionProjectionJoin…
![Page 18: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/18.jpg)
Exercise
Define and enforce relationship for your “database assessment” tables
![Page 19: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/19.jpg)
Using MS Access
Exercise: using query designer (QBE) to query “AmazonBooks” Choosing columns Specifying criteria Sorting Calculating
![Page 20: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/20.jpg)
Summary
Understand three important concepts of relational database model Relation Keys
Primary key, candidate key, alternate key Composite key Natural key, surrogate key, artificial key Foreign key
Relationship
![Page 21: The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.](https://reader035.fdocuments.net/reader035/viewer/2022062511/551490a3550346b2598b52d4/html5/thumbnails/21.jpg)
Good Resources
Edgar Frank Codd http://www.db2tridex.org/efcodd.html
MS Access tutorial http://mis.bus.sfu.ca/tutorials/MSAccess/tutorials.htm
l