Transcript Tutorial 2

COMPSCI 280
Tutorial 2
Agenda
• Views vs Tables
• Characteristics of each
• When to use each.
• Exercises to illustrate concepts discussed.
• Altering tables and records.
• Exercises.
Views
• Stored on disk as query
• Storage space is constant w.r.t. number of records.
• Is Dynamic.
• Data is can be changed.
• Allows for more granular control of data that can be modified by
users.
• Query is executed to generate result set when data on view is
requested.
Tables
• Stored on disk as records.
• Memory required scales linearly with number of records.
• Static in nature(until modified directly).
• Data is tied to the table.
• Less Granular Write permissions.
Don’t use tables to
• Repeat popular and complex queries.
• Trying to handle granular security permissions.
• Trying to ensure that information suit’s a particular audience.
Use a view when:
• More granular read/write permission is required.
• You are working with already existent information.
• You are trying to present already existent information to an audience
in a particular way.
• You are working with multiple tables and want to make future
retrieval of the same complex query in future more
efficient(indexing).
• Hiding database specific stuff from end-user.
• Dealing with information that is dynamic.
Don’t use views when
• Updating records.
• Don’t cascade views ie. Views of views of views(very inefficient).
Use a table when:
• To store new information in a database.
• To retrieve information as is from a table.
How do they depend on each other?
• They don’t in a sense.
• They are designed independently of each other.
• Tables are designed for ‘efficiency’.
• Views are designed for ‘prettiness’.
Any Questions???