SlideShare a Scribd company logo
1 of 27
Lecture 2
Relational Model and Terminology
Objectives
• In this lecture, you will learn:
– Some relational model terminologies
– The difference between the relation schema and
relational database schema
– The properties of a relation
– Relational keys
– Relational intergrity
– Views and purpose of views in relational database
2
Relational Model Terminology
• An entity is a person, place, event, or
thing/Object for which we intend to collect
data
• Examples:
– University -- Students, Faculty Members, Courses
– Airline -- Pilots, Aircraft, Routes, Suppliers
• A relation is a table with columns and rows.
– Only applies to logical structure of the database,
not the physical structure.
Relational Model Terminology
• Attribute is a named column of a relation.
• Example:
– Student -- Student Number, Name...etc
• Domain is the set of allowable values for one
or more attributes.
Attribute Domain Name Meaning Domain
Definition
Stu_id StudentID ID of a student Character:
Size 10
Relational Model Terminology
• Tuple is a row of a relation.
• Degree is the number of attributes in a relation.
• Cardinality is the number of tuples in a relation.
• Relational Database
– A collection of normalized relations with distinct
relation names.
6
Example of Attribute Domain
7
Entity and Attribute
Alternative Terminology
Attribute
Entity Occurrence
Entity Class
Conceptual data modeling notation
Student File
Id No. Name Faculty Major
1100 Ali FIT SE
1200 Mohamed FIT MIS
1300 Aisha FCM MM
1400 Hawwa FCM MM
1500 Hussain FOE CE
Alternative Terminology
Attribute
Field
Entity Occurrence
Record
Entity Class
File
Conceptual data modeling notation
File Processing Notation
Student File
Id No. Name Faculty Major
1100 Ali FIT SE
1200 Mohamed FIT MIS
1300 Aisha FCM MM
1400 Hawwa FCM MM
1500 Hussain FOE CE
Alternative Terminology
Attribute
Field
Column
Entity Occurrence
Record
Row
Entity Class
File
Table
Conceptual data modeling notation
File Processing Notation
Relational Table Notation
Student File
Id No. Name Faculty Major
1100 Ali FIT SE
1200 Mohamed FIT MIS
1300 Aisha FCM MM
1400 Hawwa FCM MM
1500 Hussain FOE CE
Database Relations
• Relation schema
• Named relation defined by a set of attribute and domain
name pairs.
• Relational database schema
• Set of relation schemas, each with a distinct name.
Relation and Relational Schema
• A relation schema is the name and the list of
attributes of a relation
• Example:
– Grade (studentId, assignmentId, points, dateSubmitted)
Relational Schema
Properties of Relation
• Relation name is distinct from all other relation names
in relational schema.
• Each cell of relation contains exactly one atomic (single)
value.
• Each attribute has a distinct name.
• Values of an attribute are all from the same domain.
• Each tuple is distinct; there are no duplicate tuples.
• Order of attributes has no significance.
• Order of tuples has no significance, theoretically.
Relational Keys
• Super key
– An attribute, or a set of attributes, that uniquely identifies a
tuple within a relation.
• Candidate Key
– Super key (K) such that no proper subset is a super key within
the relation.
• Candidate key, K, for a relation R has two properties
– Uniqueness - in each tuple of R, values of K uniquely identify
that tuple.
– Irreducibility - no proper subset of K has the uniqueness
property
Relational Key
• Super key
– Uniquely identifies each entity
• STU_NUM
• STU_NUM, STU_LNAME
• STU_NUM, STU_LNAME, STU_INIT
• Candidate key
– Minimal super key
• STU_NUM
• STU_LNAME, STU_FNAME, STU_INIT, STU_PHONE
• When a key consists of more than one attribute, it is
called a composite key
Example
• Which attributes of this table can be used as a candidate
key?
• BranchNo and PostalCode can be used as candidate keys.
• City attribute cannot be used as a candidate key, because it
has duplicate values.
BranchNo Street City PostalCode
B005 22 Deer Rd London SW1 4EH
B007 16 Argyll St Aberdeen AB2 3SU
B003 163 Main St Glasgow G11 9QX
B004 32 Manse Rd Bristol BS99 1NZ
B003 56 Clover Dr London NW10 6EU
Relational Key
• Primary Key
– Candidate key selected to identify tuples uniquely within
relation.
• Alternate Keys
– Candidate keys that are not selected to be primary key.
• Foreign Key
– Attribute, or set of attributes, within one relation that matches
candidate key of some (possibly same) relation
Relational Integrity
• Null
– Represents value for an attribute that is currently unknown or
not applicable for tuple.
– Deals with incomplete or exceptional data.
– Represents the absence of a value and is not the same as zero
or spaces, which are values.
– Example: if a student is absent for the final exam. The final
exam value of that student should be null.
Relational Integrity
• Entity Integrity
– In a base relation, no attribute of a primary key can be null.
• Primary key (BranchNo)
• Cannot insert a tuple in this relation if BranchNo is null.
BranchNo Street City PostalCode
B005 22 Deer Rd London SW1 4EH
B007 16 Argyll St Aberdeen AB2 3SU
B003 163 Main St Glasgow G11 9QX
B004 32 Manse Rd Bristol BS99 1NZ
B006 56 Clover Dr London NW10 6EU
Relational Integrity
• Entity Integrity
– In a base relation, no attribute of a primary key can
be null.
• Composite primary key (ClientNo, PropertyNo)
• Cannot insert a tuple in this relation if either ClientNo
is null, PropertyNo is null or both ClientNo and
PropertyNo are null.
ClientNo PropertyNo ViewDate Comment
CR56 PA14 24 May 01 Too small
CR76 PG4 20 April 01 Too remote
CR56 PG4 16 May 01
CR62 PA14 14 May 01 No dining room
CR56 PG36 28 April 01
Relational Integrity
• Referential Integrity
– If foreign key exists in a relation, either foreign key value
must match a candidate key value of some tuple in its home
relation or foreign key value must be wholly null.
22
Relational Integrity
BranchNo Street City PostalCode
B005 22 Deer Rd London SW1 4EH
B007 16 Argyll St Aberdeen AB2 3SU
B003 163 Main St Glasgow G11 9QX
B004 32 Manse Rd Bristol BS99 1NZ
B006 56 Clover Dr London NW10 6EU
staffNo fName lName Position Sex Salary BranchNo
SL21 Jhon White Manager M 30000 B005
SG37 Ann Beech Assistant F 12000 B003
SG14 David Ford Supervisor M 18000 B003
SA9 Mary Howe Assistant F 9000 B007
SG5 Susan Brand Manager F 24000 B003
SL41 Julie Lee Assistant F 9000 B005
Referential Integrity: Example
• BranchNo in the staff relation is a foreign key
targeting the BranchNo attribute in the Branch
relation.
• Not possible to create a staff record with non
existing BrancNo (example with B025)
• But it is possible to create a staff record with a
null branch number to cater for new staff who
has not assigned any branch office.
23
Referential Integrity: Example
• Consider the situation where we have two tables:
Employees and Managers. The Employees table
has a foreign key attribute entitled ManagedBy
which points to the record for that employee’s
manager in the Managers table.
– We may not add a record to the Employees table
unless the ManagedBy attribute points to a valid
record in the Managers table.
– If the primary key for a record in the Managers table
changes, all corresponding records in the Employees
table must be modified using a cascading update.
– If a record in the Managers table is deleted, all
corresponding records in the Employees table must be
deleted using a cascading delete.
24
Views
• Base Relation
– Named relation corresponding to an entity in conceptual schema,
whose tuples are physically stored in database.
• View
– Dynamic result of one or more relational operations operating on
base relations to produce another relation.
– A view is a virtual relation that does not necessarily exists in a
database but can be produced upon request.
– Contents of a view are defined as a query on one or more base
relations.
– Views are dynamic, meaning that changes made to base relations
that affect view attributes are immediately reflected in the view.
Views: Examples
26
Student
StudentID Student Name DOB Mark1 Mark2 Mark3
00001 Mohamed 2/2/1985 56 85 74
00002 Ahmed 3/3/1990 85 45 25
00003 Aisha 4/4/1992 75 95 35
00004 Hawwa 6/6/1989 56 54 87
Query1
StudentID Mark1 Mark2 Mark3
00001 56 85 74
00002 85 45 25
00003 75 95 35
00004 56 54 87
Query2
StudentID Student Name Mark1
00001 Mohamed 56
00002 Ahmed 85
00003 Aisha 75
00004 Hawwa 56
Purpose of Views
• Provides powerful and flexible security mechanism by hiding
parts of database from certain users.
• Permits users to access data in a customized way, so that same
data can be seen by different users in different ways, at the
same time.
• Can simplify complex operations on base relations ( Example:
join).
• A view should be designed to support external model:
– Some members of the staff should be able to see staff tuples
without the salary attribute.
– Attributes may be renamed or the order of attributes changed.
– Some members of the staff should see only a specific records.

More Related Content

Similar to Lecture 2 - Relational Model and Terminology.pptx

entity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.pptentity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.ppt
IRWANBINISMAILKPMGur1
 

Similar to Lecture 2 - Relational Model and Terminology.pptx (20)

RDBMS Model
RDBMS ModelRDBMS Model
RDBMS Model
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).ppt
 
Relational model
Relational modelRelational model
Relational model
 
19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf
 
Relational Model
Relational ModelRelational Model
Relational Model
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
entityrelationshipmodel.pptx
entityrelationshipmodel.pptxentityrelationshipmodel.pptx
entityrelationshipmodel.pptx
 
entity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.pptentity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.ppt
 
Data Models.pptx
Data Models.pptxData Models.pptx
Data Models.pptx
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data Model
 
Lecture-2 - Relational Model.pptx
Lecture-2 - Relational Model.pptxLecture-2 - Relational Model.pptx
Lecture-2 - Relational Model.pptx
 
ERD(2).ppt
ERD(2).pptERD(2).ppt
ERD(2).ppt
 
Database normalization
Database normalizationDatabase normalization
Database normalization
 
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEMDATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
 
Revision ch 3
Revision ch 3Revision ch 3
Revision ch 3
 
7.relational model
7.relational model7.relational model
7.relational model
 
3_Relational_Model.pdf
3_Relational_Model.pdf3_Relational_Model.pdf
3_Relational_Model.pdf
 
NMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.pptNMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.ppt
 
ER_model
ER_modelER_model
ER_model
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMS
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Lecture 2 - Relational Model and Terminology.pptx

  • 1. Lecture 2 Relational Model and Terminology
  • 2. Objectives • In this lecture, you will learn: – Some relational model terminologies – The difference between the relation schema and relational database schema – The properties of a relation – Relational keys – Relational intergrity – Views and purpose of views in relational database 2
  • 3. Relational Model Terminology • An entity is a person, place, event, or thing/Object for which we intend to collect data • Examples: – University -- Students, Faculty Members, Courses – Airline -- Pilots, Aircraft, Routes, Suppliers • A relation is a table with columns and rows. – Only applies to logical structure of the database, not the physical structure.
  • 4. Relational Model Terminology • Attribute is a named column of a relation. • Example: – Student -- Student Number, Name...etc • Domain is the set of allowable values for one or more attributes. Attribute Domain Name Meaning Domain Definition Stu_id StudentID ID of a student Character: Size 10
  • 5. Relational Model Terminology • Tuple is a row of a relation. • Degree is the number of attributes in a relation. • Cardinality is the number of tuples in a relation. • Relational Database – A collection of normalized relations with distinct relation names.
  • 8. Alternative Terminology Attribute Entity Occurrence Entity Class Conceptual data modeling notation Student File Id No. Name Faculty Major 1100 Ali FIT SE 1200 Mohamed FIT MIS 1300 Aisha FCM MM 1400 Hawwa FCM MM 1500 Hussain FOE CE
  • 9. Alternative Terminology Attribute Field Entity Occurrence Record Entity Class File Conceptual data modeling notation File Processing Notation Student File Id No. Name Faculty Major 1100 Ali FIT SE 1200 Mohamed FIT MIS 1300 Aisha FCM MM 1400 Hawwa FCM MM 1500 Hussain FOE CE
  • 10. Alternative Terminology Attribute Field Column Entity Occurrence Record Row Entity Class File Table Conceptual data modeling notation File Processing Notation Relational Table Notation Student File Id No. Name Faculty Major 1100 Ali FIT SE 1200 Mohamed FIT MIS 1300 Aisha FCM MM 1400 Hawwa FCM MM 1500 Hussain FOE CE
  • 11. Database Relations • Relation schema • Named relation defined by a set of attribute and domain name pairs. • Relational database schema • Set of relation schemas, each with a distinct name.
  • 12. Relation and Relational Schema • A relation schema is the name and the list of attributes of a relation • Example: – Grade (studentId, assignmentId, points, dateSubmitted) Relational Schema
  • 13. Properties of Relation • Relation name is distinct from all other relation names in relational schema. • Each cell of relation contains exactly one atomic (single) value. • Each attribute has a distinct name. • Values of an attribute are all from the same domain. • Each tuple is distinct; there are no duplicate tuples. • Order of attributes has no significance. • Order of tuples has no significance, theoretically.
  • 14. Relational Keys • Super key – An attribute, or a set of attributes, that uniquely identifies a tuple within a relation. • Candidate Key – Super key (K) such that no proper subset is a super key within the relation. • Candidate key, K, for a relation R has two properties – Uniqueness - in each tuple of R, values of K uniquely identify that tuple. – Irreducibility - no proper subset of K has the uniqueness property
  • 15. Relational Key • Super key – Uniquely identifies each entity • STU_NUM • STU_NUM, STU_LNAME • STU_NUM, STU_LNAME, STU_INIT • Candidate key – Minimal super key • STU_NUM • STU_LNAME, STU_FNAME, STU_INIT, STU_PHONE • When a key consists of more than one attribute, it is called a composite key
  • 16. Example • Which attributes of this table can be used as a candidate key? • BranchNo and PostalCode can be used as candidate keys. • City attribute cannot be used as a candidate key, because it has duplicate values. BranchNo Street City PostalCode B005 22 Deer Rd London SW1 4EH B007 16 Argyll St Aberdeen AB2 3SU B003 163 Main St Glasgow G11 9QX B004 32 Manse Rd Bristol BS99 1NZ B003 56 Clover Dr London NW10 6EU
  • 17. Relational Key • Primary Key – Candidate key selected to identify tuples uniquely within relation. • Alternate Keys – Candidate keys that are not selected to be primary key. • Foreign Key – Attribute, or set of attributes, within one relation that matches candidate key of some (possibly same) relation
  • 18. Relational Integrity • Null – Represents value for an attribute that is currently unknown or not applicable for tuple. – Deals with incomplete or exceptional data. – Represents the absence of a value and is not the same as zero or spaces, which are values. – Example: if a student is absent for the final exam. The final exam value of that student should be null.
  • 19. Relational Integrity • Entity Integrity – In a base relation, no attribute of a primary key can be null. • Primary key (BranchNo) • Cannot insert a tuple in this relation if BranchNo is null. BranchNo Street City PostalCode B005 22 Deer Rd London SW1 4EH B007 16 Argyll St Aberdeen AB2 3SU B003 163 Main St Glasgow G11 9QX B004 32 Manse Rd Bristol BS99 1NZ B006 56 Clover Dr London NW10 6EU
  • 20. Relational Integrity • Entity Integrity – In a base relation, no attribute of a primary key can be null. • Composite primary key (ClientNo, PropertyNo) • Cannot insert a tuple in this relation if either ClientNo is null, PropertyNo is null or both ClientNo and PropertyNo are null. ClientNo PropertyNo ViewDate Comment CR56 PA14 24 May 01 Too small CR76 PG4 20 April 01 Too remote CR56 PG4 16 May 01 CR62 PA14 14 May 01 No dining room CR56 PG36 28 April 01
  • 21. Relational Integrity • Referential Integrity – If foreign key exists in a relation, either foreign key value must match a candidate key value of some tuple in its home relation or foreign key value must be wholly null.
  • 22. 22 Relational Integrity BranchNo Street City PostalCode B005 22 Deer Rd London SW1 4EH B007 16 Argyll St Aberdeen AB2 3SU B003 163 Main St Glasgow G11 9QX B004 32 Manse Rd Bristol BS99 1NZ B006 56 Clover Dr London NW10 6EU staffNo fName lName Position Sex Salary BranchNo SL21 Jhon White Manager M 30000 B005 SG37 Ann Beech Assistant F 12000 B003 SG14 David Ford Supervisor M 18000 B003 SA9 Mary Howe Assistant F 9000 B007 SG5 Susan Brand Manager F 24000 B003 SL41 Julie Lee Assistant F 9000 B005
  • 23. Referential Integrity: Example • BranchNo in the staff relation is a foreign key targeting the BranchNo attribute in the Branch relation. • Not possible to create a staff record with non existing BrancNo (example with B025) • But it is possible to create a staff record with a null branch number to cater for new staff who has not assigned any branch office. 23
  • 24. Referential Integrity: Example • Consider the situation where we have two tables: Employees and Managers. The Employees table has a foreign key attribute entitled ManagedBy which points to the record for that employee’s manager in the Managers table. – We may not add a record to the Employees table unless the ManagedBy attribute points to a valid record in the Managers table. – If the primary key for a record in the Managers table changes, all corresponding records in the Employees table must be modified using a cascading update. – If a record in the Managers table is deleted, all corresponding records in the Employees table must be deleted using a cascading delete. 24
  • 25. Views • Base Relation – Named relation corresponding to an entity in conceptual schema, whose tuples are physically stored in database. • View – Dynamic result of one or more relational operations operating on base relations to produce another relation. – A view is a virtual relation that does not necessarily exists in a database but can be produced upon request. – Contents of a view are defined as a query on one or more base relations. – Views are dynamic, meaning that changes made to base relations that affect view attributes are immediately reflected in the view.
  • 26. Views: Examples 26 Student StudentID Student Name DOB Mark1 Mark2 Mark3 00001 Mohamed 2/2/1985 56 85 74 00002 Ahmed 3/3/1990 85 45 25 00003 Aisha 4/4/1992 75 95 35 00004 Hawwa 6/6/1989 56 54 87 Query1 StudentID Mark1 Mark2 Mark3 00001 56 85 74 00002 85 45 25 00003 75 95 35 00004 56 54 87 Query2 StudentID Student Name Mark1 00001 Mohamed 56 00002 Ahmed 85 00003 Aisha 75 00004 Hawwa 56
  • 27. Purpose of Views • Provides powerful and flexible security mechanism by hiding parts of database from certain users. • Permits users to access data in a customized way, so that same data can be seen by different users in different ways, at the same time. • Can simplify complex operations on base relations ( Example: join). • A view should be designed to support external model: – Some members of the staff should be able to see staff tuples without the salary attribute. – Attributes may be renamed or the order of attributes changed. – Some members of the staff should see only a specific records.

Editor's Notes

  1. LOGICAL STRUCTURE OF DATABASE Logical structure mainly consists of tablespace, segments, extents, and oracle data blocks TABLESPACE Each database is logically divided into one or more tablespaces. One or more datafiles are explicitly created for each tablespace to physically store the data of all logical structures in a tablespace. The combined size of the datafiles in a tablespace is the total storage capacity of the tablespace. SEGMENT A segment is a set of extents allocated for a certain logical structure. The segments can be of one of following type data segment,index segment,temporary segment,rollback segment. EXTENT The next level of logical database space is an extent. An extent is a specific number of contiguous data blocks, obtained in a single allocation, used to store a specific type of information. ORACLE DATABLOCKS At the finest level of granularity, Oracle database data is stored in data blocks. One data block corresponds to a specific number of bytes of physical database space on disk. The standard block size is specified by the DB_BLOCK_SIZE initialization parameter. In addition, you can specify up to five other block sizes.
  2. Definition: Referential integrity is a database concept that ensures that relationships between tables remain consistent. When one table has a foreign key to another table, the concept of referential integrity states that you may not add a record to the table that contains the foreign key unless there is a corresponding record in the linked table. It also includes the techniques known as cascading update and cascading delete, which ensure that changes made to the linked table are reflected in the primary table. Consider the situation where we have two tables: Employees and Managers. The Employees table has a foreign key attribute entitled ManagedBy which points to the record for that employee’s manager in the Managers table. Referential integrity enforces the following three rules: We may not add a record to the Employees table unless the ManagedBy attribute poi nts to a valid record in the Managers table. If the primary key for a record in the Managers table changes, all corresponding records in the Employees table must be modified using a cascading update. If a record in the Managers table is deleted, all corresponding records in the Employees table must be deleted using a cascading delete.