Databases and Architecture of Wordpress MORTENESBENSEN
Databases and Architecture of Wordpress MORTENESBENSEN FEEDBACK SO FAR?
TODAYS PROGRAM 1. Recap (08:00 08:15) 2. Databases (08:15 09:00) 1. Relational Databases 2. DBMS 3. SQL 3. Break (09:00 09:15) 4. Wordpress Architecture (09:15 09:50) 5. Exam (09:50 10:00)
1. Application layer protocols 1. HTTP (websites) 2. FTP (files) 3. SMTP/POP3/IMAP (mails) RECAP 2. The Dynamic Web 1. Client side (HTML, CSS, JavaScript) and Server side languages (PHP, Python, Node.js) 2. Dynamic website are created server side and sent to the client where they are interpreted by the browser
RECAP - EXERCISES 1. Draw a map or flow chart on how you understand the connection or roles between HTTP, FTP, IP, top-level domain names, domains, HTML and DNS. 2. Last week, we created an index.html file that can be accessed through the browser. Change the file permission of this file to 700 and try to access it through the browser. What happens? Why? 3. When clicking a link on you website, the browser reports a "404 Not found". What problem could cause this and how can you solve it? Is this problem occurring on client or server side? 4. Your website returns a 403 Forbidden page when visitors try to access it. What could cause this and how can you solve it? 5. EXTRA: the response time of your website is really slow. What can you do to check what is happening? What tools can you use?
A B FIGURE C D DATABASES
DATABASE - noun a structured set of data held in a computer, especially one that is accessible in various ways - Oxford Dictionary
DATABASE Clever way to store data Structured Easy to access and update Should ensure concurrency, integrity and recovery Different types; hierarchical, object, relational
RELATIONAL DATABASE Tables used to store data (think of an Excel sheet) Tables relate to each other through Keys Terminology: Relation (table) Attribute (column) Tuple (row)
RELATIONAL DATABASE
RELATIONAL DATABASE student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 m 2011
RELATIONAL DATABASE student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 m 2011 Attribute
RELATIONAL DATABASE student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 m 2011 Tuple Attribute
RELATIONAL DATABASE student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 m 2011 Tuple Attribute Relation
KEYS Keys are used to provide access between relations Primary keys are unique identifiers Can be any unique attribute Foreign keys matches primary keys of other relations Can be any attribute
RELATIONAL DATABASE - KEYS student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 23456 Line Andersen 09-05- 1988 bsdt 2010 18-10- 1990 bdmd 2011 study_line bsdt bdmd name SoMware Development and Technology Digital Media and Design studyline
RELATIONAL DATABASE - KEYS student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 23456 Line Andersen 09-05- 1988 bsdt 2010 18-10- 1990 bdmd 2011 study_line bsdt bdmd name SoMware Development and Technology Digital Media and Design studyline
RELATIONAL DATABASE - KEYS student Foreign key student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 23456 Line Andersen 09-05- 1988 bsdt 2010 18-10- 1990 bdmd 2011 Primary key (unique) study_line bsdt bdmd name SoMware Development and Technology Digital Media and Design studyline
Database Management System Responsible for creation, maintenance, and usage of databases Provides access to databases through Query Language Handles access, concurrency, integrity and recovery DBMS
STRUCTURED QUERY LANGUAGE Developed in the 70s SEQUEL (Structured English Query Language) SQL Programming language for usages of DBMS MySQL implements SQL and is used for Wordpress
SQL - QUERIES 1. Retrieve data from a database 2. Keywords 1. SELECT query 2. FROM tables to use 3. WHERE restriction on rows 4. GROUP BY group rows 5. ORDER BY select columns to use for ordering 3. ; to end statements SELECT name FROM students WHERE study_line = bdmd ;
QUERIES SELECT name FROM student WHERE study_line = bdmd ; student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 23456 Line Andersen 09-05- 1988 bsdt 2010 18-10- 1990 bdmd 2011 Result?
QUERIES SELECT name FROM student WHERE study_line = bdmd ; student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 23456 Line Andersen 09-05- 1988 bsdt 2010 18-10- 1990 bdmd 2011 Result = Lise Andersen
QUERIES * = Wildcard SELECT * FROM student WHERE enrolment_year > 2010 ORDER BY date_of_birth student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 ebuss 2011 Result?
QUERIES * = Wildcard SELECT * FROM student WHERE enrolment_year > 2010 ORDER BY date_of_birth student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 ebuss 2011 Result? 34567 Peter Jensen 1986-12-01 ebuss 2011 23456 Lise Andersen 1990-10-18 bdmd 2011
SQL DATA MANIPULATION Change data in a database Keywords INSERT - insert data INTO table to insert into VALUES values to insert UPDATE update existing data SET assignment to variable DELETE delete data INSERT INTO student (student_id,name, date_of_birth, study_line, enrolment_year) VALUES (45678, Marie Madsen, 1989-03-05, bdmd, 2010);
DATA MANIPULATION INSERT INTO student (student_id,name, date_of_birth, study_line, enrolment_year) VALUES (45678, Marie Madsen, 1989-03-05, bdmd, 2010); student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 ebuss 2011 Result?
DATA MANIPULATION INSERT INTO student (student_id,name, date_of_birth, study_line, enrolment_year) VALUES (45678, Marie Madsen, 1989-03-05, bdmd, 2010); student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 ebuss 2011 student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 ebuss 2011 45678 Marie Madsen 05-03- 1989 bdmd 2010
DATA MANIPULATION UPDATE student SET name = Maria Madsen WHERE student_id = 45678; student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 ebuss 2011 45678 Marie Madsen 05-03- 1989 bdmd 2010 Result?
DATA MANIPULATION UPDATE student SET name = Maria Madsen WHERE student_id = 45678; student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 ebuss 2011 45678 Marie Madsen 05-03- 1989 bdmd 2010 student student_id name date_of_birth study_line enrolment_year 12345 Hans Hansen 09-05- 1988 bsdt 2010 23456 Line Andersen 18-10- 1990 bdmd 2011 34567 Peter Jensen 01-12- 1986 ebuss 2011 45678 Maria Madsen 05-03- 1989 bdmd 2010
THE BIG PICTURE
THE BIG PICTURE database SELECT * FROM news.. database result
WORDPRESS 1. WORDPRESS
WORDPRESS Open source blogging / cms tool Based on php / mysql (database) / JQuery Free online blog or download and install wordpress.com vs wordpress.org Most popular CMS on the internet Requirements: PHP 5.2.4 or up MySQL 5.0 or up
POSTS, PAGES The content of a Wordpress blog is organized in to Post and pages Posts are articles that you publish on your blog E.g. news, updates etc. Pages are static sites on your blog E.g. About Me
WIDGETS, PLUGINS Plugins extends the functionality of your blog E.g. check comments for spam, connect with social media, SEO Widgets are plugins with a visual interface New comments, top post You can find Plugins and Themes online and install them from the admin panel http://wordpress.org/extend/plugins/
THEMES Themes define the look and presentation of your blog Basics style.css defining the look index.php defining the presentation You can find Themes online and install the from the admin panel More on styling and themes next time! http://codex.wordpress.org/theme
THE LOOP The code that talks with your database and outputs content! <?php get_header(); if (have_posts()) : while (have_posts()) : the_post(); the_content(); endwhile; endif; get_sidebar(); get_footer();?> More on this later in the course http://codex.wordpress.org/the_loop
THE LOOP The code that talks with your database and outputs content! <?php get_header(); if (have_posts()) : while (have_posts()) : the_post(); the_content(); endwhile; endif; get_sidebar(); get_footer();?> More on this later in the course Wordpress core functions http://codex.wordpress.org/the_loop
WORDPRESS CORE 1. A number of.php files in your Wordpress installation 2. Gives you the functionality you need to interact with the database 3. Should not be changed http://codex.wordpress.org/wordpress_files get_adjacent_post get_boundary_post get_children get_extended get_next_post get_next_posts_link get_permalink get_the_excerpt get_the_post_thumbnail get_post get_post_ancestors get_post_mime_type get_post_status get_post_format get_edit_post_link get_delete_post_link get_previous_post
EXERCISES 1. Explore the database behind Wordpress 2. Designing your portfolio 3. Changelog
EXAM Portfolio handin at 16/12-2013 No oral defense Requirements: Wordpress installation CSS & PHP Changes Changelog Design page Social Media Integration 5 posts about exercises
EXAM Portfolio handin at 16/12-2013 No oral defense Requirements: Wordpress installation CSS & PHP Changes Changelog Design page Social Media Integration 5 posts about exercises
MORTENESBENSEN