digital media technology week 7. □ database □ dbms □ data vs. information □ data redundancy...

31
Digital Media Technology Week 7

Upload: dawson-heart

Post on 01-Apr-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

Digital Media Technology

Week 7

Page 2: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

□ Database

□ DBMS

□ Data vs. Information

□ Data redundancy

□ Tables, Rows, Columns, Records, Fields

□ Relational data model

□ RDBMS

Page 3: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

foreign keyprimary key

TREASURE_ID TITLE CREATOR LIBRARY SUBJECT YEAR

1 Sidereus Nuncius 7 7 SCI 1610

2 Requiem KV 626 2 1 MUS 1791

3 Rabbit Hunt, in the lower left Brueghel 1560. 3 3 ART 1560

4 De antiquitate Britanicae Ecclesiae 8 4 ART 1572

5 Vedute di Roma con scene di costume 6 6 HIS 1810

6 Corrected page proofs of 'Les Fleurs du mal' 1 2 HIS 1857

7 Vinegar Hill, charge of the 5th Dragoon Guards 4 5 HIS 1880

8 Poster of "Internationale Ausstellung für Buchgewerbe und Graphik" 5 9 ART 1914

9 Fontana dei Fiumi a Piazza Navona 9 6 ART 1734

CREATOR_ID

NAME_LAST NAME_FIRST YEAR_OF_BIRTH YEAR_OF_DEATH COUNTRY_BORN

1 Baudelaire Charles 1821 1867 FR

2 Mozart Wolfgang Amadeus 1756 1791 AT

3 Bruegel The Elder Pieter 1525 1569 BE

4 Sadler William 1782 1839 IE

5 Tiemann Walter 1876 1951 DE

6 Macchiavelli Giacomo 1756 1811 IT

7 Galilei Galileo 1564 1642 IT

8 Parker Matthew 1504 1575 GB

9 Wittel Caspar van 1655 1736 NL

10 Molyneux Daniel 1568 1632 IE

Page 4: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

FK = PK

Page 5: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

CREATE TABLE TREASURE(

TREASURE_ID INT (4) NOT NULL AUTO_INCREMENT,TITLE VARCHAR (150),CREATOR INT,LIBRARY CHAR(6), SUBJECT CHAR(3), YEAR INT (4),

PRIMARY KEY (TREASURE_ID),

FOREIGN KEY (CREATOR) REFERENCES CREATOR ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (LIBRARY) REFERENCES LIBRARY ON DELETE RESTRICT ON UPDATE CASCADE,FOREIGN KEY (SUBJECT) REFERENCES SUBJECT ON DELETE RESTRICT ON UPDATE CASCADE

);

Page 6: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

Entity Relationship Diagrams

Page 7: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

PERSON

P_ID

NAME

E-MAIL

PHONE

DATE_OF_BIRTH

Attributes

PK is underlined

Page 8: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

BOOK

PERSON

COMPANY

Page 9: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

□ Cardinality of many is represented by a line ending in a crow's foot.

BOOK

COMPANY

PERSON

Page 10: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

PERSON COMPANY

many many

EMPLOYMENT

P_ID C_ID

P_IDC_ID

E_ID

many

one

many

one

Page 11: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

Making an ERD

□ Identify entities□ Consider the cardinality of the relations

between these entities□ One-to-one relations must be removed –

these entitites can be combined in a single entity

□ Change many-to-many relations into one-to-many relations by making use of linking tables

□ Add attributes

Page 12: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

General principle: avoid fields which contain values which can be derived from other fields.

PRICE No. ITEMS ORDERED

TOTAL PRICE

€20 5 €100

PLACE POPULATION LAND AREA DENSITY

New York city 7,322,564 308.9 23,705

Page 13: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

code name

uk Great Britain

fr France

ne The Netherlands

be Belgium

A look-up table

(based on ISO 3166-1993 )

Page 14: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

Name Country_born

Shelley, Percy Bysshe Great Britain

Swinburne, Algernon Charles

Britain

Cowper, William United Kingdom

Coleridge, Samuel Taylor U.K.

Page 15: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

Name Country_born

Shelley, Percy Bysshe uk

Swinburne, Algernon Charles

uk

Cowper, William uk

Coleridge, Samuel Taylor uk

Page 16: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

Referential Integrity

□ Each foreign key should correspond to an existing primary key.

□ Most DBMSs take measures to prevents users or applications from entering inconsistent data.

Page 17: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

CREATE TABLE BOOK( B_ID INT NOT NULL AUTO_INCREMENT,

TITLE VARCHAR (50), AUTHOR INT,LANGUAGE VARCHAR (40),PUBLISHER INT,EXTENT INT,YEAR INT(4),PRIMARY KEY (B_ID),FOREIGN KEY (AUTHOR) REFERENCES

PERSON ON DELETE RESTRICT ON UPDATE CASCADE,

FOREIGN KEY (PUBLISHER) REFERENCES COMPANY ON DELETE RESTRICT ON UPDATE CASCADE );

Page 18: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

□ Implementation□ Data entry□ Database Design

Page 19: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data
Page 20: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

HTMLhttp

SQL

SERVER

CLIENT

HTML

db

Page 21: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

□ SQL: Structured Query Language

□ Supported by most RDBMSs.

□ Makes use of regular English words

Page 22: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

Interpretation continuum

Data: relatively unstructured

Information: very structured

Source: Obrst and Liu, Knowledge representation, Ontological Engineering and Topic Maps, in: XML Topic Maps, 2003

Page 23: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

foreign keyprimary key

TREASURE_ID TITLE CREATOR LIBRARY SUBJECT YEAR

1 Sidereus Nuncius 7 7 SCI 1610

2 Requiem KV 626 2 1 MUS 1791

3 Rabbit Hunt, in the lower left Brueghel 1560. 3 3 ART 1560

4 De antiquitate Britanicae Ecclesiae 8 4 ART 1572

5 Vedute di Roma con scene di costume 6 6 HIS 1810

6 Corrected page proofs of 'Les Fleurs du mal' 1 2 HIS 1857

7 Vinegar Hill, charge of the 5th Dragoon Guards 4 5 HIS 1880

8 Poster of "Internationale Ausstellung für Buchgewerbe und Graphik" 5 9 ART 1914

9 Fontana dei Fiumi a Piazza Navona 9 6 ART 1734

CREATOR_ID

NAME_LAST NAME_FIRST YEAR_OF_BIRTH YEAR_OF_DEATH COUNTRY_BORN

1 Baudelaire Charles 1821 1867 FR

2 Mozart Wolfgang Amadeus 1756 1791 AT

3 Bruegel The Elder Pieter 1525 1569 BE

4 Sadler William 1782 1839 IE

5 Tiemann Walter 1876 1951 DE

6 Macchiavelli Giacomo 1756 1811 IT

7 Galilei Galileo 1564 1642 IT

8 Parker Matthew 1504 1575 GB

9 Wittel Caspar van 1655 1736 NL

10 Molyneux Daniel 1568 1632 IE

Page 24: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

SELECT TITLE, YEARFROM TREASURE ;

TITLE YEAR

Sidereus Nuncius 1610

Requiem KV 626 1791

Rabbit Hunt, in the lower left Brueghel 1560.

1560

De antiquitate Britanicae Ecclesiae 1572

Vedute di Roma con scene di costume

1810

Corrected page proofs of 'Les Fleurs du mal'

1857

Vinegar Hill, charge of the 5th Dragoon Guards

1880

Poster of "Internationale Ausstellung für Buchgewerbe und Graphik"

1914

Fontana dei Fiumi a Piazza Navona 1734

Page 25: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

SELECT * FROM TREASURE ;

treasure_id title year creator library subject

1 Sidereus Nuncius 1610 7 7 SCI

2 Requiem KV 626 1791 2 1 MUS

3 Rabbit Hunt, in the lower left Brueghel 1560.

1560 3 3 ART

4 De antiquitate Britanicae Ecclesiae

1572 8 4 ART

5 Vedute di Roma con scene di costume

1810 6 6 HIS

6 Corrected page proofs of 'Les Fleurs du mal'

1857 1 2 HIS

7 Vinegar Hill, charge of the 5th Dragoon Guards

1880 4 5 HIS

8 Poster of "Internationale Ausstellung für Buchgewerbe und Graphik"

1914 5 8 ART

9 Fontana dei Fiumi a Piazza Navona

1734 9 6 ART

Page 26: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

SELECT TITLE, YEARFROM TREASUREORDER BY YEAR ;

TITLE YEAR

Rabbit Hunt, in the lower left Brueghel 1560.

1560

De antiquitate Britanicae Ecclesiae 1572

Sidereus Nuncius 1610

Fontana dei Fiumi a Piazza Navona 1734

Requiem KV 626 1791

Vedute di Roma con scene di costume

1810

Corrected page proofs of 'Les Fleurs du mal'

1857

Vinegar Hill, charge of the 5th Dragoon Guards

1880

Poster of "Internationale Ausstellung für Buchgewerbe und Graphik"

1914

Page 27: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

SELECT NAME_LAST, NAME_FIRST, (YEAR_OF_DEATH - YEAR_OF_BIRTH) AS AGE FROM CREATOR ;

NAME_LAST NAME_FIRST AGE

Baudelaire Charles 46

Mozart Wolfgang Amadeus

35

Bruegel The Elder Pieter 44

Sadler William 57

Tiemann Walter 75

Macchiavelli Giacomo 55

Galilei Galileo 78

Parker Matthew 71

Wittel Caspar van 81

Molyneux Daniel 64

Page 28: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

SELECT TITLE, YEARFROM TREASUREWHERE YEAR > 1800 ;

TITLE YEAR

Vedute di Roma con scene di costume

1810

Corrected page proofs of 'Les Fleurs du mal'

1857

Vinegar Hill, charge of the 5th Dragoon Guards

1880

Poster of "Internationale Ausstellung für Buchgewerbe und Graphik"

1914

Page 29: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

SELECT DISTINCT SUBJECTFROM TREASURE ;

SUBJECT

ART

HIS

MUS

SCI

Page 30: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

Exercise 5

Page 31: Digital Media Technology Week 7. □ Database □ DBMS □ Data vs. Information □ Data redundancy □ Tables, Rows, Columns, Records, Fields □ Relational data

Exercise 6