This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
CS 338: Computer Applications in Business: Databases (Fall 2014)
• Professional Users:• Database Administrators• Database Designers• System Analysts• Application Programmers
• End Users• Casual• Parametric• Sophisticated• Standalone
3
Define different types of database users.Define different types of database users.
Review Advantages of DBMS
Controlling redundancy
Restricting unauthorized access
Efficient Execution of queries and updates
Efficient search techniques
Backup and recovery
Multiple user interfaces
Representing complex relationships among data
Enforcing integrity constraints
Permitting inferencing and actions using rules
4
List some advantages of using a DBMS.List some advantages of using a DBMS.
Nathan Wilson
-maybe one request per day, not very many-many requests per day-know what they are doing, make specific applications to access DB-use some software that uses a database in the background
Nathan Wilson
Nathan Wilson
3
CS 338: Computer Applications in Business: Databases (Fall 2014)
Proposed by Dr. E. Codd of IBM Research in the 1970 in the following paper "A Relational Model for Large Shared Data Banks,“ Communications of the ACM, June 1970
Relational Model
• The first commercial implementations available in early 1980s
Revolutionary idea…
• Relation is a mathematical concept based on the idea of sets• Represents data as a collection of relations
Based on the concept of a Relation
Relational Data Model Concepts
10
• A relation is similar to a table of values (informal)• Typically contains a set of rows
Data as a collection of relations…
• Data elements in each row represent certain facts that typically correspond to a real-world entity or relationship
• In formal model, rows are called Tuples
Row
• Each column has a column header• Gives some meaning of the data items in that column• In formal model, column header is called an attribute name (or
simply an attribute)
Column
6
CS 338: Computer Applications in Business: Databases (Fall 2014)
A degree (or arity) of a relation is the number of attributes n of its relation schema
Formal Definition - Schema
12
• denoted by R(A1, A2, ...,An)• A relation is composed of
• relation name R and a list of attributes: A1, A2, ..., An
The relation schema (or description) of a Relation
• PRODUCTS (UPC, Title, Price, Quantity)• PRODUCTS is the relation name• Defined over four attributes: UPC, title, price and quantity
Example
• Each attribute has a domain or a set of valid (atomic) values• Denoted by dom(An) • Example: the domain of UPC is 12-digit numbers• The domain may have a data type and/or format
Domain
7
CS 338: Computer Applications in Business: Databases (Fall 2014)
Cardinality of a relation is the number of tuples m of a relation (or total number of values in a domain)
Formal Definition – State & Tuple
13
• denoted by r(R)• is a set of n-tuples r = {t1, t2, …, tm}
A relation (or relation state) r of the relation schema R(A1, A2, ...,An)
• A tuple is an ordered set of values t = <v1, v2, …, vn>• Each value vi, 1 ≤ 𝑖 ≤ 𝑛, 𝑖𝑠 𝑎𝑛 𝑒𝑙𝑒𝑚𝑒𝑛𝑡 𝑜𝑓 𝑑𝑜𝑚(𝐴𝑖) 𝑜𝑟 𝑖𝑠 𝑎 𝑠𝑝𝑒𝑐𝑖𝑎𝑙
𝑁𝑈𝐿𝐿 𝑣𝑎𝑙𝑢𝑒 (𝑤𝑖𝑙𝑙 𝑏𝑒 𝑑𝑖𝑠𝑐𝑢𝑠𝑠𝑒𝑑 𝑙𝑎𝑡𝑒𝑟)
Tuple
• A row in the PRODUCTS relation is 4-tuple consisting of four values. For instance: <0088590934387, iPhone 4, $399.99, 10>• This is called a 4-tuple as it has 4 values• A tuple (or row) in PRODUCTS relation
Example
Formal Definition – State (revisited)…
14
• is a mathematical relation of degree n on the domainsdom(A1), dom(A2), … dom(An), which is a subset of the Cartesian product (denoted by�) of the domains of its attributes that define R
• The Cartesian product specifies all possible combinations of values from underlying domains• Product of cardinalities of all domains represents the total number
of possible instances or tuples that ever exist in any relation state r(R)
• Of all these possible combinations, a relation state at a given time –the current relation state reflects only valid tuples that represent a particular state of the real world
A relation state r(R) is …
𝑟 𝑅 ⊆ � 𝑑𝑜𝑚 𝐴 � 𝑑𝑜𝑚 𝐴 � … � 𝑑𝑜𝑚 𝐴 )
Nathan Wilson
Nathan Wilson
[?] == X
Nathan Wilson
8
CS 338: Computer Applications in Business: Databases (Fall 2014)
• R(A1, A2, …, An) is the relation schema• R is the name of the relation• A1, A2, …, An are the attributes of the relation• r(R) a specific state of relation R
this is a set of valid tuples
• r(R) = {t1, t2, …, tm} Each n-tuple t is an ordered list of n values• t = < v1, v2, … vn > Each value vi is an element of dom(Ai)
Formally…
𝒓 𝑹 ⊆ � 𝒅𝒐𝒎 𝑨𝟏 � 𝒅𝒐𝒎 𝑨𝟐 � … � 𝒅𝒐𝒎 𝑨𝒏 )
Example 1 Formal Definition
16
• Let dom(A1) = {1, 2, 3}• Let dom(A2) = {a, b, c}
• The relation state 𝒓 𝑹 ⊆ � 𝒅𝒐𝒎 𝑨𝟏 � 𝒅𝒐𝒎 𝑨𝟐 )• Any subset of the Cartesian product is a relation• For example: r(R) could be {<1,a>, <1, b>, <2,c>} where it
has three 2-tuple
Let R(A1, A2) be a relation schema
𝒕𝒉𝒆𝒏 𝒅𝒐𝒎 𝑨𝟏 � 𝒅𝒐𝒎 𝑨𝟐 � … � 𝒅𝒐𝒎 𝑨𝒏 is all possible combinations
1 a
1 b
2 c
9
CS 338: Computer Applications in Business: Databases (Fall 2014)
(John, USA, MATH)(John, USA, CSCI)(John, Canada, MATH)(John, Canada, CSCI)(Joanna, USA, MATH)(Joanna, USA, CSCI)(Joanna, Canada, MATH)(Joanna, Canada, CSCI)
Example 2 Formal Definition
• The relation schema R(Name, Country, Course)• Let us assume the subset
{ (John, USA, MATH), (Joanna, Canada, CSCI) }
which is a subset of the Cartesian product that reflects only valid tuples that represent a particular state of the real world
r(R) = { (John, USA, MATH), (Joanna, Canada, CSCI) }• Now this is our relation or table
Now there could be some subset out of the 8 pairs that we only need (relation state)
NAME COUNTRY COURSE
John USA MATHJoanna Canada CSCI
18
10
CS 338: Computer Applications in Business: Databases (Fall 2014)
Ordering of values within a tuple and an alternative definition of a relation• Order of attributes and values is not that important • As long as correspondence between attributes and values
maintained• We will consider the attributes in R(A1, A2, ...,An) and the values in
t=<v1, v2, ..., vn> to be ordered
• An alternative definition: making the ordering of values in a tuple unnecessary• Tuple considered as a function from attributes to values• tj : {A1, A2, A3, …, An} dom(A1) ∪ dom(A2) ∪ … ∪ dom(An) • Use notation tj[Ai] or tj.Ai to refer to tuple’s value vi from dom(Ai)• Similarly, tj[Au, Aw, ..., Az] and tj.(Au, Aw, ..., Az) refer to the sub-
tuple of values <vu, vw, ..., vz> from tj for attributes Au, Aw, ..., Az• Therefore, a tuple is a set of <attribute, value> pairs
2
Characteristics of Relations
24
Ordering of values within a tuple and an alternative definition of a relation
• Turn it on:• Press the ON/OFF button. A solid blue light should appear next to the top Power
button. If your clicker came wrapped in packaging, pull out the small plastic tab on the back to activate the batteries.
• Change the frequency to AA:• The instructions on the back of your clicker say
• Press and hold the ON/OFF button until the top blue Power light flashes. Enter the 2 letter frequency code (AA).
• The code for each classroom (AA for DWE 1501) is posted near the podium at the front of the class. When a clicker is turned off it forgets any changes in frequency and the clicker frequency is again AA when the clicker is turned on.
• How do I know if my vote has been received? • When the receiver acknowledges a vote, the Vote Status light on the clicker (the third
light) will flash green for a moment. If it flashes red instead, then either the voting period hasn't started, or the receiver didn't respond to your vote. In the latter case, change the frequency of your clicker if necessary and vote again. Raise your hand for assistance if you don't see a green response.
• Can I change my vote/choice? • Yes. While the voting process is active, you can vote as often as you like. Only your last
(most recent) choice/vote is recorded. 33
Practice Clicker Question A
• What faculty are you in?• A: Applied Health Sciences
• B: Arts
• C: Environment
• D: Mathematics
• E: Science or Engineering
34
18
CS 338: Computer Applications in Business: Databases (Fall 2014)