Introduction to Physical DB

by K. Yue

1. Introduction

Advanced Example:

An article on flash memory and database lists important characteristics of flash memory for database consideration:

2. Physical Database Design

3. Denormalization, Partitioning and Clustering

4. MySQL Indexes

Example: Using AdventureWorks, a small data warehouse example created by Microsoft. You can try out the effect of indexes.

-- using AdventureWorks

-- Basic information about AdventureWorks.address.
use AdventureWorks;
desc address;
select count(*) from address;

-- Q1
select distinct AddressLine1, City, PostalCode
from address
order by PostalCode
limit 300;

-- Q2
select distinct AddressLine1, City, PostalCode
from address
where PostalCode = 98055;

-- Q3
select distinct AddressLine1, City, PostalCode
from address
where PostalCode = 98055 or PostalCode = 83402;

-- Q4
select distinct AddressLine1, City, PostalCode
from address
where PostalCode between 90000 and 92000
limit 300;

-- create index
create index postal_index on address(postalCode);
desc address;

-- Q1
select distinct AddressLine1, City, PostalCode
from address
order by PostalCode
limit 300;

-- Q2
select distinct AddressLine1, City, PostalCode
from address
where PostalCode = 98055;

-- Q3
select distinct AddressLine1, City, PostalCode
from address
where PostalCode = 98055 or PostalCode = 83402;

-- Q4
select distinct AddressLine1, City, PostalCode
from address
where PostalCode between 90000 and 92000
limit 300;

-- clean up
drop index postal_index on address;
desc address;