Digital Media Technology Week 11
Feb 13, 2016
Digital Media Technology
Week 11
□ Implementation□ Database Design
□ Retrieval
□ Data entry
□ XPath - SQL
□ DTD/Schema - ERD
Similarities betweeen techniques and concepts
Booktrade Database
□ Indexes to transcriptions from the Bohn archive
□ Relations between letters, persons, companies, titles
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);
INSERT INTO CREATOR VALUES ('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') ;
UPDATE CREATORSET NAME_LAST='Charles Pierre'WHERE PID= 1 ;
DELETE DATABASE TREASURE ;
DROP TABLE CREATOR ;
SELECT TITLE, YEARFROM TREASURE ;
TITLE YEARSidereus 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
SELECT * FROM TREASURE ;
treasure_id title year creator library subject1 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
SELECT TITLE, YEARFROM TREASUREORDER BY YEAR ;
TITLE YEARRabbit 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
SELECT TITLE, YEARFROM TREASUREWHERE YEAR > 1800 ;
TITLE YEARVedute 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
SELECT DISTINCT SUBJECTFROM TREASURE ;
SUBJECTART
HIS
MUS
SCI
SQL Functions □ COUNT ( ) ;□ SUM ( ) ;□ AVG ( ) ;□ MIN ( ) ;□ MAX ( ) ;
SELECT COUNT(*)FROM TREASURE ;
9
SELECT COUNTRY_BORN, COUNT(*)FROM CREATORGROUP BY COUNTRY_BORN ;
COUNTRY_BORNAT 1BE 1DE 1FR 1GB 1IE 2IT 2NL 1
11
1
1
creator_id name_last name_first
year_of_birth
year_of_death
country_born
2 Mozart Wolfgang Amadeus
1756 1791 AT
3 Bruegel The Elder
Pieter 1525 1569 BE
5 Tiemann Walter 1876 1951 DE1 Baudelaire Charles 1821 1867 FR8 Parker Matthew 1504 1575 GB4 Sadler William 1782 1839 IE
10 Molyneux Daniel 1568 1632 IE6 Macchiavelli Giacomo 1756 1811 IT7 Galilei Galileo 1564 1642 IT9 Wittel Caspar van 1655 1736 NL
1111221
COUNTRY_BORN
ie 2
it 2
SELECT COUNTRY_BORN, COUNT(*)FROM CREATORGROUP BY COUNTRY_BORN HAVING COUNT(*) >= 2 ;
Joining tables
SELECT NAME_FIRST, NAME_FIRST, TITLEFROM TREASURE, CREATORWHERE CREATOR = CREATOR_ID ;
NAME_FIRST NAME_LAST TITLECharles Charles Corrected page proofs of 'Les
Fleurs du mal'Wolfgang Amadeus
Wolfgang Amadeus
Requiem KV 626
Pieter Pieter Rabbit Hunt, in the lower left Brueghel 1560.
William William Vinegar Hill, charge of the 5th Dragoon Guards
Walter Walter Poster of "Internationale Ausstellung für Buchgewerbe und Graphik"
Giacomo Giacomo Vedute di Roma con scene di costume
Galileo Galileo Sidereus NunciusMatthew Matthew De antiquitate Britanicae
EcclesiaeCaspar van Caspar van Fontana dei Fiumi a Piazza
Navona
HTMLPHP
http
SQL
SERVER
CLIENT
HTMLdb
1. Which table(s) contains the information that you need? 2. Are you interested in all the records in this/these table(s)? 3. Are you interested in the actual contents of the records or in statistical information
about the records in the table? If so, would you like to receive one answer for the entire table, or would you like to receive different answers for different types of records?
4. Which columns do you want to see? 5. Do you want to see duplicate values or are you only interested in different values? 6. Do the records in the result set need to be sorted in any particular way?
A structured approach to writing queries