Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational.

Similar presentations


Presentation on theme: "Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational."— Presentation transcript:

1 Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational databases are and how they work Understand how to interact with a database using PHP Understand how to output to a client Understand how to design & construct a database Understand how to construct a site that uses dynamic content Gain an understanding of the cultural importance of databases in current culture – both professional and artistic

2 Class 1Intro to Databases Understand the architecture behind web database applications A 3-tier application is an application program that is organized into three major parts, each of which is distributed to a different place or places in a network. The three parts are: The Client Tier presentation interface Html or flash The Middle Tier application logic PHP The Database Tier database and programming related to managing it MySQL

3 Class 1Intro to Databases What relational databases are and how they work A relational database is a collection of data items organized as a set of formally-described tables from which data can be accessed or reassembled in many different ways without having to reorganize the database tables. In addition to being relatively easy to create and access, a relational database has the important advantage of being easy to extend. After the original database creation, a new data category can be added without requiring that all existing applications be modified. The relational database was invented by E. F. Codd at IBM in 1970.

4 Class 1Intro to Databases What relational databases are and how they work Database User Table User NamePasswordCountry FredApple1 MaryOrange2 SueKiwi1 Country Table IDCountry 1Canada 2Mexico 3USA A database is made up of tables Each table has defined columns or fields rows or records

5 Class 1Intro to Databases What relational databases are and how they work The standard user and application program interface to a relational database is the structured query language (SQL). SQL statements are used both for interactive queries for information from a relational database and for gathering data for reportsSQL

6 Class 1Intro to Databases Understand how to interact with a database using PHP PHP is used to ask questions and retrieve answers from a Database PHP is designed to work with SQL databases. It can format questions in a way the database can understand PHP has several specific commands that allow it to talk to MySQL PHP is used to output HTML to a browser, or pass information to another client-side application like Flash

7 Class 1Intro to Databases Understand how to output to a client Data stored in a database is usually free of any presentation markup. This means that when it is retrieved from a database nothing determines what it will look like, or how it will be displayed. This separation of content and display means that the same content can be retrieved and displayed in several formats or mediums HTML FLASH PDA CELL PHONE PDF ETC It also means that applications that use databases can be easily updated or redesigned.

8 Class 1Intro to Databases Understand how to design & construct a database The design of a database is one of the most important parts of a dynamic website. It determines What type of data can be stored How easily information can be accessed How fast information can be accessed What types of relationships can be made between the data How easily a database can be extended Database Architects (DBAs) usually design databases

9 Class 1Intro to Databases Understand how to construct a site that uses dynamic content Most site that use dynamic content display their pages in templates A template is an html page (etc) with “buckets” for content To design templates you need to understand How to retrieve data from a database How to format this data for display The basics of graphic design & user interface

10 Class 1Intro to Databases Understand how to construct a site that uses dynamic content

11 Class 1Intro to Databases Understand how to construct a site that uses dynamic content

12 Class 1Intro to Databases The cultural importance of databases – both professional and artistic changes in how we organize perceive separation of content and context content and display

13 Class 1Intro to Databases PHP Basics What is PHP? PHP: Hypertext Preprocessor PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. Like any language, PHP is made up of Variable types Built in functions It supports user defined functions It is designed to work with SQL It has it’s own syntax

14 Class 1Intro to Databases PHP Basics Variable types The “type” of a variable describes what sort of information a variable can store, as well as how much space that information takes up. (Think Tupperware) Scalar Types Variables of a scalar type can contain a single value at any given time Boolean$registered=TRUE; integer$age=26; float$weekly_pay=12,444.33; string$name=“Fred”; Constants define("pi", 3.14159);

15 Class 1Intro to Databases PHP Basics Syntax Starting and Ending a program Ending a statement Statements end with a semi-colon, “;”. (Forgetting this is a common mistake) File Extensions In order for a server to recognize a php file it must end in.php Comments # this is a comment // this is also a comment

16 Class 1Intro to Databases PHP Basics Basic Commands Declaring a variable assigns a value to a variable $name=“Fred”; Print Print outputs as text. It can be used for plain text files or html print(“Hi”);

17 Class 1Intro to Databases PHP Basics Outputting to HTML HTML Hi. Our class is called “Intro to Databases”. PHP ”); print(“ ”); print(“ Hi. Our class is called \“Intro to Databases \“. ”); print(“ ”); print(“ ”); ?> Note that the quote is escaped.

18 Class 1Intro to Databases PHP Basics Outputting to HTML with variables HTML Hi. My name is Sharon. PHP ”); print(“ ”); print(“ Hi. My name is $name. ”); print(“ ”); print(“ ”); ?>

19 Class 1Intro to Databases PHP Basics Simple User Defined Functions ”); print(“ ”); print(“$a + $b ”); print(“is equal to ”); add_two_numbers($a, $b); print(“ ”); print(“ ”); function add_two_numbers($a, $b){ $c= $a + $b; print(“$c”); } ?>

20 Class 1Intro to Databases PHP Basics Simple User Defined Functions - A Better Way ”); print(“ ”); print(“$a + $b is equal to $c”); print(“ ”); print(“ ”); function add_two_numbers($a, $b){ $c= $a + $b; return $c; } ?>

21 Class 1Intro to Databases PHP Basics Constructing a simple template ”); print(“ ”); print(“ ”); // display content here print(“$content”); // end display content // end page print(“ ”); print(“ ”); print(“ ”); ?>

22 Class 1Intro to Databases PHP Basics Common Errors ”); print(“ ”); print(“ ”); // display content here print(“$content”); // end display content // end page print(“ ”); print(“ ”); print(“ ”); ?> Parse error: parse error in /home/denning/www/sp2004/cl_01/examples/template.php on line 8 Here the quotes are not escaped


Download ppt "Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational."

Similar presentations


Ads by Google