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
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
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.
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
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
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
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.
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
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
Class 1Intro to Databases Understand how to construct a site that uses dynamic content
Class 1Intro to Databases Understand how to construct a site that uses dynamic content
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
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
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", );
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 recogonize a php file it must end in.php
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”);
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.