Download presentation
Presentation is loading. Please wait.
Published byCaroline Coughlin Modified over 10 years ago
1
Relational Model Reading: C&B, Chap 2, 3 & 4
2
Dept. of Computing Science, University of Aberdeen 2 In this lecture you will learn The concept of Model Simple definitions of terminology in Relational Model Why relational model is important? Initial idea of Relational Querying
3
Dept. of Computing Science, University of Aberdeen 3 Introduction DBMS models data with respect to –Machine physical storage of data involves low level details that are not important for user –User logical view of data (tables) We focus on Users DATA MODEL
4
Dept. of Computing Science, University of Aberdeen 4 The Concept of Model A model represents something. –At a level of detail suitable for its purpose For example, an architects model of a bridge –Architects model brings the bridge to life even before its construction Models can be: –Blueprints for building the real somethings (such as bridges) –Useful for testing (model a bridge and test it before construction) –Handy for learning (you start driving lessons on a simulator) All our thinking is based on models of things –We build models of everything Thinking with models is considered SMART
5
Dept. of Computing Science, University of Aberdeen 5 Learning with Relational Model Theory of databases involves many models –Relational model, ER model Relational model is the users data model and we learn it first DBMSs that use relational model are called Relational Database Management Systems (RDBMS) Apply our learning on a few real RDBMS (MSAccess & MYSQL) –Mostly in practical classes –Also in lectures Hopefully this training will help us with other RDBMS as well (such as SQL Server and Oracle)
6
Dept. of Computing Science, University of Aberdeen 6 Why Relational Model? Most modern database software is based on relational model –Relational model is what the user sees in a RDBMS Relational Model has a simple logical structure (as we will see later) It is intuitive (as we will see later) Relational model has its origins in sound mathematics –Set theory and theory of relations (hence the name relational) –We study the mathematics later in the course Relational Model describes the pure concepts behind real database systems –Real systems at times may have unfaithful implementations of these pure concepts
7
Dept. of Computing Science, University of Aberdeen 7 What is relational model? A logical representation of a database Proposed by IBMs E. F. Codd in 1970 –Won a Turing Award for the model!! Earlier data models were not relational. They were –Hierarchical (tree) or –Network (graph) We focus on relational models in this course
8
Dept. of Computing Science, University of Aberdeen 8 Relational Model is simple Relational Database: a collection of connected tables (relations) –Named Tables (relations) have Named Columns (attributes) Unnamed Rows (tuples) –Domain: a set of allowable values for one or more columns –Relationships – links or connections –Keys (primary, foreign) –Integrity Constraints Its that simple!
9
Dept. of Computing Science, University of Aberdeen 9 Example: DreamHome DreamHome models data in a typical real estate business –you will use this database in the practical DreamHome has data related to –Branch offices –Staff in each branch office –… Branch office data –Branch number –Address Staff data –Staff number –Staff details Since staff belong to a branch office, there is a relationship between staff data and branch office data. –Staff and Branch tables are linked (connected)
10
Dept. of Computing Science, University of Aberdeen 10 Example: DreamHome 2 branchNoStreetCityPostcode B00522 Deer RdLondonSW1 4EH B00716 Argyll StAberdeenAB2 3SU B003163 Main StGlasgowG11 9QX B00432 Clover DrBristolBS99 1NZ B00256 Clover DrLondonNW10 6EU staffNofNameLNamePositionSexDOBSalarybranchNo SL21JohnWhiteManagerM1-Oct-4530000B005 SG37AnnBeechAssistantF10-Nov-6012000B003 SG14DavidFordSupervisorM24-Mar-5818000B003 SA9MaryHoweAssistantF19-Feb-709000B007 SG5SusanBrandManagerF13-Jun-4024000B003 SL41JulieLeeAssistantF13-Jun-659000B005 Relation Attributes Branch Staff Primary KeyForeign Key
11
Dept. of Computing Science, University of Aberdeen 11 Relation (Table) Relation has two parts –Schema Name of the relation and the set of attributes & their respective domains For example, Branch (branchNo:domain1, street: domain2, city:domain3, postcode:domain4) –Instance Set of attributes and their values in a tuple For example, (branchNo:B005, street: 22 Dee Street, city:Aberdeen,postcode:AB25 1AB)
12
Dept. of Computing Science, University of Aberdeen 12 Key A key is an attribute or set of attributes that uniquely identify a row A table may have many candidate keys Primary Key: Key selected for unique identification of rows –For example, branchNo in the Branch table –Cannot be NULL Foreign Key: an attribute or a set of attributes in one table that refer to a row in another table –For example, branchNo in Staff table
13
Dept. of Computing Science, University of Aberdeen 13 Properties of relations Rows & columns can be in any order no two rows are identical all values belonging to a particular attribute are from the same domain attributes are atomic attributes may have a null value (but not the primary key)
14
Dept. of Computing Science, University of Aberdeen 14 Relational model is intuitive Many common datasets naturally fit relational model Telephone directory –Directory(Name:domain1, Address:domain2, TelNo:domain3) Class Attendance Sheets –Attendance(Name:domain1, IDNo:domain2, Signature: domain3) Try with other datasets you know
15
Dept. of Computing Science, University of Aberdeen 15 Data Retrieval: Relational Querying The main strength of relational model: supports simple yet powerful data retrieval (querying in general) –The whole purpose of modelling data is to be able to retrieve data items efficiently Output of a query is modelled as a relation (table) In RDBMS users view data always in terms of tables –if you learn relational model well you can find it easy to use databases SQL (see-quel): a popular query language for relational databases.
16
Dept. of Computing Science, University of Aberdeen 16 Example: Relational Querying Consider the branch relation from the DreamHome database Query: we want a list of branches in London Output is a sub-relation (sub-table) of the Branch relation (table) branchNoStreetCityPostcode B00522 Deer RdLondonSW1 4EH B00716 Argyll StAberdeenAB2 3SU B003163 Main StGlasgowG11 9QX B00432 Clover DrBristolBS99 1NZ B00256 Clover DrLondonNW10 6EU branchNoStreetCityPostcode B00522 Deer RdLondonSW1 4EH B00256 Clover DrLondonNW10 6EU London Branches Branch
17
Dept. of Computing Science, University of Aberdeen 17 Conclusion Relational model of database: a collection of connected tables –Conceptually relational model is simple –Querying the data is the main goal of relational modelling User interactions with RDBMS are through SQL (Query language) only We now focus on learning SQL –Later we will learn how to organize data into a relational model (under database design)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.