lecture 02 the relational data model. advantages of database
TRANSCRIPT
![Page 1: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/1.jpg)
Lecture 02
The Relational Data ModelThe Relational Data Model
![Page 2: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/2.jpg)
Advantages of Database
![Page 3: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/3.jpg)
Advantages of Database• Data Consistency• Better Data Security• Faster Application Development• Economy of Scale• Better Concurrency Control• Better Backup and Recovery Facility
![Page 4: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/4.jpg)
The Range ofDatabase Applications
• Personal Database – standalone desktop database
• Workgroup Database – local area network (<25 users)
• Department Database – local area network (25-100 users)
• Enterprise Database – wide-area network (hundreds or thousands of users)
![Page 5: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/5.jpg)
Models, Schemas and States• A data model defines the constructs
available for defining a schema– defines possible schemas
• A schema defines the constructs available for storing the data – defines database structure – limits the possible database states
• A database state (or instance) is all the data at some point in time
the database content
![Page 6: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/6.jpg)
Models, Schemas and States• data model
– fixed by the DBMS
• schema – defined by the DB designer– generally fixed once defined *
• database state– changes over time due to user updates
* schema modifications are possible once the database is populated, but this generally causes difficulties
![Page 7: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/7.jpg)
RELATION SCHEMASANDRELATION INSTANCES
![Page 8: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/8.jpg)
Relation Schemas• A relation is defined by
a name and a set of attributes
• Each attribute has a name and a domain– a domain is a set of possible values– all domains are sets of atomic values– RDM does not recommend complex data types– domains may contain a special null value
![Page 9: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/9.jpg)
![Page 10: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/10.jpg)
Definition: Relation Schema• Relation Schema
– R is the relation name– A1 … An are the attribute names
• Domains are denoted by
• degree = the number of attributes
R(A1, A2, … , An)
dom(Ai)
![Page 11: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/11.jpg)
Characteristics of Relations• A relation is a set
– tuples are unordered– no duplicate tuples
• Attribute values within tuples are ordered– values are matched to attributes by position
– alternate definition defines a tuple as a set of (name,value) pairs,which makes ordering of tuple unnecessary(we won’t use this definition)
![Page 12: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/12.jpg)
Characteristics of Relations• Values in tuples are atomic
• Each Column has distinct name
• The values of the attribute come from the same domain
• The order of the column is immaterial
• Each row/tuple/record is distinct
![Page 13: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/13.jpg)
SQL: Relation States• A relation is viewed as a table
• The attributes define the columns of the table
• Each row in the table holds related values for each attribute– a row often represents a conceptual entity (object)
• Values in each column must come from the domain of the attribute– the values are instances of the attribute type
![Page 14: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/14.jpg)
Example Schema
![Page 15: Lecture 02 The Relational Data Model. Advantages of Database](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e9f5503460f94ba23f7/html5/thumbnails/15.jpg)