copyright © 2003-2008 curt hill the relational model of database basic organization and terms

10
Copyright © 2003-2008 Curt Hill The Relational Model of Database Basic organization and terms

Upload: laureen-tyler

Post on 02-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Copyright © 2003-2008 Curt Hill The Relational Model of Database Basic organization and terms

Copyright © 2003-2008 Curt Hill

The Relational Model of Database

Basic organization and terms

Page 2: Copyright © 2003-2008 Curt Hill The Relational Model of Database Basic organization and terms

Copyright © 2003-2008 Curt Hill

Relational• Form is that of a table• Each table has

– A fixed number of columns• The contents of a field in a column may be

empty

– A variable number of rows

• A row is known as a tuple• A column is a set of fields and is all of

the same type• Different tables may have different

columns

Page 3: Copyright © 2003-2008 Curt Hill The Relational Model of Database Basic organization and terms

Copyright © 2003-2008 Curt Hill

Relation• In theory a relation is a set

– No ordering at all

• In practice our tuples are often ordered

• In theory a tuple is also a set• In practice a tuples are ordered

– We are able to reorder them easily

Page 4: Copyright © 2003-2008 Curt Hill The Relational Model of Database Basic organization and terms

Copyright © 2003-2008 Curt Hill

Terms• Entity• Relationship• Attribute• Tuple• Table• Relation• Often many synonyms

Page 5: Copyright © 2003-2008 Curt Hill The Relational Model of Database Basic organization and terms

Copyright © 2003-2008 Curt Hill

Definition: Schema• Schema - describes the rows of a table

– A set of attribute names• The definition of kinds of attributes

making up a tuple

– The definition of the file type– This is usually static, that is the file

definition does not change over time much

• Subschema– A piece of a larger schema

Page 6: Copyright © 2003-2008 Curt Hill The Relational Model of Database Basic organization and terms

Schema Flavors• Conceptual Schema

– AKA logical schema– Describes data in terms of tables

• Physical Schema– How the data is actually stored– Viewpoint is the disk or hardware

• External Schema– A subset or different view of the

conceptual schema– Different users may see different

external schemaCopyright © 2003-2008 Curt Hill

Page 7: Copyright © 2003-2008 Curt Hill The Relational Model of Database Basic organization and terms

Copyright © 2003-2008 Curt Hill

Definition: Body• The actual tuples making up a

relation at any one time• This usually varies over time• The contents of the file can

change often and substantially

Page 8: Copyright © 2003-2008 Curt Hill The Relational Model of Database Basic organization and terms

Copyright © 2003-2008 Curt Hill

Terms Defined• Degree

– Count of attributes

• Cardinality of a relation– Number of tuples present

Page 9: Copyright © 2003-2008 Curt Hill The Relational Model of Database Basic organization and terms

Copyright © 2003-2008 Curt Hill

Keys• Candidate

– Minimal collection of one or more fields that unique identify tuple

• Primary– One of the candidate keys– Who decides?

•Business expert not db expert

• Foreign– Referenced primary in another

table

Page 10: Copyright © 2003-2008 Curt Hill The Relational Model of Database Basic organization and terms

Copyright © 2003-2008 Curt Hill

Other keys• Alternate

– A candidate key that is not the primary

• Secondary– (Not really a relational term)– Any set of attributes

• Does not have to be unique• Does not have to be a candidate key,

though candidate keys used in indices are often called secondary

– Used as a key in an index structure