0% found this document useful (0 votes)
27 views5 pages

Lecture Slides Week2 014 Logical Data Independence

Logical data independence allows queries to be written without considering the physical storage of data. For example, a query can select data from a view called "StorePrice" without knowing if the data comes from a join of two tables or from a single stored table. Physical data independence means that changes to the physical storage, such as moving a file or adding an index, do not require changes to queries. Indexes help databases efficiently find "needles in haystacks" or specific results within large datasets, and are automatically used by queries when appropriate to ensure fast response times regardless of the size of the data.

Uploaded by

Richard Ding
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

Lecture Slides Week2 014 Logical Data Independence

Logical data independence allows queries to be written without considering the physical storage of data. For example, a query can select data from a view called "StorePrice" without knowing if the data comes from a join of two tables or from a single stored table. Physical data independence means that changes to the physical storage, such as moving a file or adding an index, do not require changes to queries. Indexes help databases efficiently find "needles in haystacks" or specific results within large datasets, and are automatically used by queries when appropriate to ensure fast response times regardless of the size of the data.

Uploaded by

Richard Ding
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Key Idea: Logical Data Independence

views

SELECT * FROM my_sequences

logical data independence


relations

SELECT seq FROM ncbi_sequences WHERE seq = GATTACGATATTA;

physical data independence

5/11/13

f = fopen(table_file); fseek(10030440); files and while (True) { pointers fread(&buf, 1, 8192, f); if (buf == GATTACGATATTA) { Bill Howe, eScience Institute 1 . . .

What are Views? ! A view is just a query with a name ! We can use the view just like a real table
!"#$%&'$()$*+$,"-./$
0)%&1.)$()$2'+($,"&,$)3)4#$ 51)4#$4),14'.$&$4)6&7+'8$$ !)$.&#$,"&,$,")$6&'91&9)$-.$ :&69);4&-%&66#$%6+.)*<$
5/11/13 Bill Howe, UW 2

View example A view is a relation defined by a query


Purchase(customer, product, store) Product(pname, price) StorePrice(store, price)

CREATE VIEW StorePrice AS SELECT x.store, y.price FROM Purchase x, Product y WHERE x.pid = y.pid

This is like a new table StorePrice(store,price)


Magda Balazinska - CSE 344, Fall 2012 3

Customer(cid, name, city) Purchase(customer, product, store) Product(pname, price)

StorePrice(store, price)

How to Use a View?


! A "high end" store is a store that sold some product over 1000. For each customer, find all the high end stores that they visit. Return a set of (customername, high-end-store) pairs.
SELECT DISTINCT z.name, u.store FROM Customer z, Purchase u, StorePrice v WHERE z.cid = u.customer AND u.store = v.store AND v.price > 1000

Magda Balazinska - CSE 344, Fall 2012

Key Idea: Indexes


! Databases are especially, but not exclusively, effective at Needle in Haystack problems:
! Extracting small results from big datasets ! Your query will always* finish, regardless of dataset size. ! Indexes are easily built and automatically used when appropriate
CREATE INDEX seq_idx ON sequence(seq); SELECT seq FROM sequence WHERE seq = GATTACGATATTA;

5/11/13

Bill Howe, eScience Institute

*almost

You might also like