Informatics tools in network science
description
Transcript of Informatics tools in network science
![Page 1: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/1.jpg)
Informatics tools in network science
seminar 2
Database handling
![Page 2: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/2.jpg)
storing information
(local) filesmemory database
speed
capacity
![Page 3: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/3.jpg)
technical features
pure databaseconcept
real-time database(transactions and concurrency)
data warehouse system(big, reporting and analysis)distributed database
in-memory database
![Page 4: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/4.jpg)
off-topic: raid technologies
“striping” “mirroring” “byte level parity” “block level parity”
against SPOF (Single Point Of Failure)
![Page 5: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/5.jpg)
relational database storing data in tables
terminology:
![Page 6: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/6.jpg)
relational database storing data in tables data types
![Page 7: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/7.jpg)
relational database storing data in tables data types table relations
ARTICLES
• title• keyword• authorstoring articles
![Page 8: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/8.jpg)
relational database storing data in tables data types table relations
ARTICLES
• title• keyword1• keyword2• keyword3• author
more keyword? no problem…
![Page 9: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/9.jpg)
relational database storing data in tables data types table relations
ARTICLES
• title• keyword1• keyword2• keyword3• author1• author2• author3
more author? why not…
![Page 10: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/10.jpg)
relational database storing data in tables data types table relations
ARTICLES
• title• keyword1• keyword2• keyword3• author1• author2• author3• author1_contact• author2_contact• author3_contact
and what about the contacts?
![Page 11: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/11.jpg)
relational database storing data in tables data types table relations
ARTICLES
• title• keyword1• keyword2• keyword3• author1• author2• author3• author1_contact• author2_contact• author3_contact
there is some serious problem here…
• what if there is a 4th author?• what if usually there are 2 authors (wasting memory)• contacts are redundant!
![Page 12: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/12.jpg)
relational database storing data in tables data types table relations
KEYWORDS
• keyword
AUTHORS
• name• contact
ARTICLES
• title
![Page 13: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/13.jpg)
relational database storing data in tables data types table relations
KEYWORDS
• keyword ID• keyword
AUTHORS
• author ID• name• contact
ARTICLES
• article ID• title
ARTICLES_KEYWORDS
• article ID• keyword ID
ARTICLES_AUTHORS
• article ID• author ID
![Page 14: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/14.jpg)
relational database • storing data in tables
• data types
• table relationsKEYWORDS
AUTHORS
ARTICLES
ARTICLES_KEYWORDS
ARTICLES_AUTHORS
article ID title
1 “first title”
2 “other title”
article ID keyword ID
1 1
1 2
2 2
keyword ID keyword
1 “cell”
2 “neurology”
author ID name contact
1 “Bill” “555-2316”
2 “Joe” “[email protected]”
article ID author ID
1 2
2 1
2 2
![Page 15: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/15.jpg)
could be worse…
![Page 16: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/16.jpg)
Database servers
MySQL(free / professional)
sqLite(easy)
Oracle(professional)
MS Access(MS Office)
MS SQL Server(professional)
postgre SQL(object oriented)
some example:
![Page 17: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/17.jpg)
install MySQL Download MySQL Community Server 5.1 from:
http://dev.mysql.com/downloads/mysql/5.1.html
![Page 18: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/18.jpg)
install MySQL Download MySQL GUI tools from: http://dev.mysql.com/downloads
![Page 19: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/19.jpg)
SQL• SQL = Structured Query Language
SELECT * FROM BookWHERE price > 10.00 ORDER BY title;
Selecting all attributes of given data rows…
…of table called “Book”,
…where the price is higher than 100.
Give back this list ordered by the title of the title.
Title Author Price
Linked A. L. Barabási 12.5
The Lord of the Links J. K. Lowling 40.0
Weak Links P. Csermely 15.0
![Page 20: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/20.jpg)
SQL SQL = Structured Query Language
SELECTisbn, title, price, price * 0.06 AS sales_tax
FROM Book WHERE price > 100.00 ORDER BY title;
INSERT INTO My_table (field1, field2, field3)VALUES ('test', 'N', NULL);
UPDATE My_tableSET field1 = 'updated value‘
WHERE field2 = 'N';
DELETE FROM My_tableWHERE field2 = 'N';
![Page 21: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/21.jpg)
MySQL Query Browser
![Page 22: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/22.jpg)
SQL – join tables
animals
id animal
1 “cat”
2 “dog”
3 “cow”
SELECT *
FROM animals, foods;
+------------+--------+----------+-------+| animals.id | animal | foods.id | food |+------------+--------+----------+-------+| 1 | cat | 1 | milk || 1 | cat | 2 | bone || 1 | cat | 2 | grass || 2 | dog | 1 | milk || 2 | dog | 2 | bone || 2 | dog | 2 | grass || 3 | cow | 1 | milk || 3 | cow | 2 | bone || 3 | cow | 2 | grass |+------------+--------+----------+-------+
CROSS JOIN
foods
id food
1 “milk”
2 “bone”
3 “grass”
Let us ask MySQL to list data from both table!
![Page 23: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/23.jpg)
SQL – join tables
people
pid name phone
1 “Mr Brown” “01225 708225”
2 “Miss Smith”
“01225 899360 ”
3 “Mr Pullen” “01380 724040”
sellingspid sid selling
1 1 “Old House Farm”
3 2 “The Willows”
3 3 “Tall Trees”
3 4 “The Melksham Florist”
4 5 “Dun Roamin”
Let us ask MySQL to list data from both table!
mysql> select name, phone, sellingfrom people join sellings on people.pid = sellings.pid;+-----------+--------------+----------------------+| name | phone | selling |+-----------+--------------+----------------------+| Mr Brown | 01225 708225 | Old House Farm || Mr Pullen | 01380 724040 | The Willows || Mr Pullen | 01380 724040 | Tall Trees || Mr Pullen | 01380 724040 | The Melksham Florist |+-----------+--------------+----------------------+4 rows in set (0.01 sec)
mysql>
INNER JOIN
SELECT name, phone, selling
FROM people join sellingson people.pid = selling.pid;
![Page 24: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/24.jpg)
SQL – join tables
people
pid name phone
1 “Mr Brown” “01225 708225”
2 “Miss Smith”
“01225 899360 ”
3 “Mr Pullen” “01380 724040”
sellingspid sid selling
1 1 “Old House Farm”
3 2 “The Willows”
3 3 “Tall Trees”
3 4 “The Melksham Florist”
4 5 “Dun Roamin”
Let us ask MySQL to list data from both table!
mysql> select name, phone, sellingfrom people, sellings where people.pid = sellings.pid;+-----------+--------------+----------------------+| name | phone | selling |+-----------+--------------+----------------------+| Mr Brown | 01225 708225 | Old House Farm || Mr Pullen | 01380 724040 | The Willows || Mr Pullen | 01380 724040 | Tall Trees || Mr Pullen | 01380 724040 | The Melksham Florist |+-----------+--------------+----------------------+4 rows in set (0.01 sec)
mysql>
INNER JOIN = cross join + WHERE but faster!!
SELECT name, phone, selling
FROM people join sellingson people.pid = selling.pid;
SELECT name, phone, selling
FROM people, sellings
WHERE people.pid = selling.pid;
![Page 25: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/25.jpg)
SQL – join tables
people
pid name phone
1 “Mr Brown” “01225 708225”
2 “Miss Smith”
“01225 899360 ”
3 “Mr Pullen” “01380 724040”
sellingspid sid selling
1 1 “Old House Farm”
3 2 “The Willows”
3 3 “Tall Trees”
3 4 “The Melksham Florist”
4 5 “Dun Roamin”
Let us ask MySQL to list data from both table!
SELECT name, phone, selling
FROM people left join sellingson people.pid = selling.pid;
LEFT JOIN
mysql> select name, phone, selling from people left join sellings on people.pid = sellings.pid; +------------+--------------+----------------------+| name | phone | selling |+------------+--------------+----------------------+| Mr Brown | 01225 708225 | Old House Farm || Miss Smith | 01225 899360 | NULL || Mr Pullen | 01380 724040 | The Willows || Mr Pullen | 01380 724040 | Tall Trees || Mr Pullen | 01380 724040 | The Melksham Florist |+------------+--------------+----------------------+5 rows in set (0.00 sec)
mysql>
![Page 26: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/26.jpg)
SQL – join tables
people
pid name phone
1 “Mr Brown” “01225 708225”
2 “Miss Smith”
“01225 899360 ”
3 “Mr Pullen” “01380 724040”
sellingspid sid selling
1 1 “Old House Farm”
3 2 “The Willows”
3 3 “Tall Trees”
3 4 “The Melksham Florist”
4 5 “Dun Roamin”
Let us ask MySQL to list data from both table!
SELECT name, phone, selling
FROM people right join sellingson people.pid = selling.pid;
RIGHT JOIN
mysql> select name, phone, selling from people left join sellings on people.pid = sellings.pid; +------------+--------------+----------------------+| name | phone | selling |+------------+--------------+----------------------+| Mr Brown | 01225 708225 | Old House Farm || Mr Pullen | 01380 724040 | The Willows || Mr Pullen | 01380 724040 | Tall Trees || Mr Pullen | 01380 724040 | The Melksham Florist || NULL | NULL | Dun Romain |+------------+--------------+----------------------+5 rows in set (0.00 sec)
mysql>
![Page 27: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/27.jpg)
SQL – join tables
sellingspid sid selling
1 1 “Old House Farm”
3 2 “The Willows”
3 3 “Tall Trees”
3 4 “The Melksham Florist”
4 5 “Dun Roamin”
SELECT name, COUNT(sid) as selling_num
FROM people join sellingson people.pid = selling.pid
GROUP BY selling.pid;
people
pid name phone
1 “Mr Brown” “01225 708225”
2 “Miss Smith”
“01225 899360 ”
3 “Mr Pullen” “01380 724040”
mysql> select name, phone, sellingfrom people, sellings where people.pid = sellings.pid;+-----------+--------------+----------------------+| name | phone | selling |+-----------+--------------+----------------------+| Mr Brown | 01225 708225 | Old House Farm || Mr Pullen | 01380 724040 | The Willows || Mr Pullen | 01380 724040 | Tall Trees || Mr Pullen | 01380 724040 | The Melksham Florist |+-----------+--------------+----------------------+4 rows in set (0.01 sec)
mysql>
+-----------+--------------+| name | selling_num |+-----------+--------------+| Mr Brown | 1 || Mr Pullen | 3 |+-----------+--------------+
Use aggregated function and join:
![Page 28: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/28.jpg)
SQL – join tables
sellingspid sid selling
1 1 “Old House Farm”
3 2 “The Willows”
3 3 “Tall Trees”
3 4 “The Melksham Florist”
4 5 “Dun Roamin”
SELECT name, COUNT(sid) as selling_num
FROM people left join sellingson people.pid = selling.pid
GROUP BY selling.pid;
people
pid name phone
1 “Mr Brown” “01225 708225”
2 “Miss Smith”
“01225 899360 ”
3 “Mr Pullen” “01380 724040”
+------------+--------------+| name | selling_num |+------------+--------------+| Mr Brown | 1 || Miss Smith | 0 || Mr Pullen | 3 |+------------+--------------+
mysql> select name, phone, selling from people left join sellings on people.pid = sellings.pid; +------------+--------------+----------------------+| name | phone | selling |+------------+--------------+----------------------+| Mr Brown | 01225 708225 | Old House Farm || Miss Smith | 01225 899360 | NULL || Mr Pullen | 01380 724040 | The Willows || Mr Pullen | 01380 724040 | Tall Trees || Mr Pullen | 01380 724040 | The Melksham Florist |+------------+--------------+----------------------+5 rows in set (0.00 sec)
mysql>
Use aggregated function and (left) join:
![Page 29: Informatics tools in network science](https://reader036.fdocuments.in/reader036/viewer/2022070404/56813b21550346895da3d92e/html5/thumbnails/29.jpg)
SQL – more info
http://www.w3schools.com/SQl/default.asp MySQL 5.1 Reference Manual:
http://dev.mysql.com/doc/refman/5.1/en/index.html http://en.wikipedia.org/wiki/SQL