2. relationalmodel.pdf - Introduction to the Relational...

This preview shows page 1 - 12 out of 39 pages.

Introduction to theRelational ModelCMPT 354Jian Pei[email protected]
OutlineStructure of Relational DatabasesDatabase SchemaKeysSchema DiagramsRelational Query LanguagesThe Relational AlgebraJ. Pei: CMPT 354 -- Introduction to the Relational Model2
Let Us Start from an Example – RelationInstructorattributes(or columns)tuples(or rows)J. Pei: CMPT 354 -- Introduction to the Relational Model3
Relation Schema and InstanceA1,A2, …,AnareattributesR= (A1,A2, …,An) is arelation schemaExample:instructor= (ID,name, dept_name, salary)A relation instancerdefined over schemaRis denotedbyr(R).The current values of a relation are specified by a tableAn elementtof relationris called atupleand is represented by arowin a tableJ. Pei: CMPT 354 -- Introduction to the Relational Model4
AttributesThe set of allowed values for each attribute is called thedomainofthe attributeAttribute values are (normally) required to beatomic; that is,indivisibleThe special valuenullis a member of every domain. Indicated thatthe value is “unknown” or “unavailable”Attention: the null value causes complications in the definition ofmany operationsJ. Pei: CMPT 354 -- Introduction to the Relational Model5
Relations are UnorderedOrder of tuples is irrelevant (tuples may be stored in an arbitraryorder)Example:instructorrelation with unordered tuplesJ. Pei: CMPT 354 -- Introduction to the Relational Model6
Database SchemaDatabase schema: the logical structure of the databaseDatabase instance: a snapshot of the data in the database at a giveninstant in timeExampleschema:instructor(ID, name, dept_name, salary)Instance: a tableSomewhat similar to data classes in PythonJ. Pei: CMPT 354 -- Introduction to the Relational Model7
KeysKÍRis asuperkeyofRif values forKare sufficient to identify a unique tuple of eachpossible relationr(R)Example:{ID} and {ID,name} are both superkeys ofinstructor.SuperkeyKis acandidate keyifKis minimal – no proper subsets ofKare still a superkeyExample:{ID} is a candidate key forInstructorOne of the candidate keys is selected to be theprimary key by database designerForeign keyconstraint: value in one relation must appear in anotherReferencingrelationReferencedrelationExample:dept_namein instructoris a foreign key frominstructorreferencingdepartmentJ. Pei: CMPT 354 -- Introduction to the Relational Model8
Schema Diagram for University DatabaseJ. Pei: CMPT 354 -- Introduction to the Relational Model9
To-Do ListWhat are the following statements are CORRECT?
J. Pei: CMPT 354 -- Introduction to the Relational Model10
Relational Query LanguagesProcedural versus non-procedural, or declarative“Pure” languages:Relational algebra

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 39 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
Hassan
Tags
Relational model, Jian Pei

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture