Tuesday, June 19, 2018

Chapter 5-7 Synopsis


Chapter 5

  • SQL, structured query language, is a group of special words used exclusively for interacting with databases.
  •  CREATE DATABASE is used for creating a new database.
  • CREATE TABLE is used for creating a new table.
  • SQL is case-insensitve
  • INSERT is used to populate tables.
  • SHA1() function is one way to encyrpt data. Creates an encrypted string that is always exactly 40 characters long.
  • NOW() function populates date, time, and timestamp columns.
  • A SELECT query returns rows of records.
  • To limit what rows are return based on certain criteria when using SELECT, conditionals may be added to the query.
  • Conditionals use the term WHERE.
  • LIKE and NOT LiKE are used—primarily with strings—in conjunction with two wildcard characters: the underscore ( _ ), which matches a single character, and the percentage sign (% ), which matches zero or more characters.
  •  To give a meaningful order to a query's results, use an ORDER BY clause.
  • LIMIT states how many records are returned.
  • UPDATE syntax is used to update records.
  • DELETE command is used to delete data from the database.
  • An alias is a symbolic renaming of an item used in a query.
Chapter 6

  • Normalization is the process in which a database designer eliminates redundancies and other problems that would undermine the integrity of the database.
  • There are two types of keys, primary and foreign.
    • A primary key is a unique identifier that has to abide by certain rules.
    • Foreign keys are the representation in Table B of the primary key from Table A
  • Database relationships refer to how the data in one table relates to the data in another.
    • A one-to-one relationship applies if one item in Table A coincides with one item in Table B.
    • A one-to-many relationship is if one item in Table A can apply to multiple items in Table B.
    • A many-to-many relationship is multiple items in Table A can apply to multiple items in Table B.
Chapter 7
  • To find messages in a MySQL form, one would need to first find the forum_id for MySQL.
  • A join is an SQL query that uses two or more tables and produces a virtual table of results
  • A inner join returns all of the records from the named tables wherever a match is made.
  • An outer join will return records that are matched by both tables and will return records that don't match.
  • A right outer join does the opposite of a left outer join: it returns all of the applicable records from the right hand table, along with matches from the left-hand table.
  • FULLTEXT searches require a FULLTEXT index.
  • The SHOW TABLE STATUS query returns a fair amount of information about each table in the database, including the table’s storage engine.


Tuesday, June 12, 2018

Chapter 4 Synopsis

Chapter Four:
  • MySQL is the world's most popular open-source data application and is commonly used with PHP.
  • The MySQL software itself comes with the database server (stores actual data), different client applications (for interacting with the database server) and several utilities.
  • When creating databases and tables, one must come up with names (identifiers) that are clear, meaningful, and easy to type.
    • Identifiers should only contain letters, numbers, and the underscore (no spaces).
    • Should not be the same as an existing keyword.
    • Case sensitive.
    • <64 Characters
    • Unique within its realm.
      • This rule means that a table cannot have two columns with the same name and a database cannot have two tables with the same name. (Same column name in two different tables in the same database, however, is allowed.
  • When creating a table, MySQL requires that you explicitly state what sort of information each column will contain.
    • Text (strings)
    • Numbers
    • Dates and times
  • If length attribute is defined, any characters beyond the allotted amount will be truncated.
  • ENUM - a column that stores only one value of a possible several thousand.
  • SET - a columns that allows storing for several of up to 64 possible values.
  • CHAR will always be stored as a string the length of the column.
  • VARCHAR only requires as much as space as the string itself.
  • NULL value is stating that the field has no known value. Since most should, to force a field to have a valuer, add NOT NULL to the description of it's column type.
  • Primary keys must always have:
    • a value
    • a value that never changes
    • a unique value for each record in the able.
  • Unsigned (number type) limits the stored data to positive numbers and 0.
  • A client is necessary to communicate with MySQL's server, such as mysql client.
  • phpMyAdmin is one of the most popular applications written in PHP and it's sole purpose is to provide an interface to a MySQL server.

Sunday, June 3, 2018

Chapters 1-3 Synopsis


Chapter One: Introduction to PHP
·        PHP is an HTML-embedded scripting language, meaning that you can intermingle PHP and HTML code within the same file.
o   Starts with a simple web page.
o   The encoding you use in a file dictates what characters can be represented and therefore, which languages can be used.
o   Example of a PHP script:
§  1   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
    1.0 Transitional//EN" "http://www.w3.org/
    TR/xhtml1/DTD/xhtml1-transitional.dtd">
2   <html xmlns="http://www.w3.org/1999/
    xhtml" xml:lang="en" lang="en">
3   <head>
4      <meta http-equiv="Content-Type"
       content="text/html; charset=utf-8" />
5      <title>Basic PHP Page</title>
6   </head>
7   <body>
8      <!-- Script 1.2 - first.php -->
9      <p>This is standard HTML.</p>
10  <?php
11  ?>
12  </body>
13  </html>
·        Anything written within these tags will be treated by the web server as PHP.
·        PHP files must have the proper extension, which tells the server to treat the script in a special way, namely, a PHP page.
·        Web servers use .html for standard web pages and .php for PHP files.
·        When sending data to web browsers, echo may be used.
Chapter Two : Programming with PHP
Chapter two explores HTML forms and how to handle them. Operators are discussed as well as loops and arrays.
·        First you create the HTML form itself, then you create the corresponding PHP script.
·        Examples of form tags:
<form action="script.php" method="post"></form>
·        Most important form tag is action, which dictates to which page the form data will be sent. Method is also an attribute.
·        Different inputs are possible such as text boxes and radio buttons.
·        PHP’s three primary terms for creating conditionals are if, else, and else if.
·        Every conditional begins with a clause.
·        Validating form data may be achieved by using “isset()”, which tests if a variable has a value.
·        Arrays are structured as a series of key-value pairs, where one pair is an item or an element of that array.
·        PHP supports two kinds of arrays: indexed, which uses numbers and keys, and associative, which uses strings as keys.
·        Examples of loops:
o   While:
§  while (condition) {
        // Do something.
}
·        For:
o   for (initial expression; condition;
closing expression) {
       // Do something.
}


Chapter Three: Creating Dynamic Web Sites
               Dynamic Web sites, as opposed to the static ones on which the Web was first built, are easier to maintain, are more responsive to users, and can alter their content.
·        Including multiples files are used to extract the HTML from the PHP or to separate out commonly used processes.
·        PHP has four functions for incorporating external files: include(), include_once(), require(), and require_once().
·        An absolute path references a file starting from the root directory of the computer.
·        A relative path uses the referencing (parent) file as the starting point.
·        The include() and require() functions are exactly the same when working properly but behave differently if they fail.
·        To have one page both display and handle a form, a conditional must check witch action (display or handle) should be taken.
·        A GET request is the first request, which loads the form.
·        The second request is a POST request method, that submits the form.
·        A sticky form is a standard HTML form that remembers how you filled it out.
·        The value attribute is used to preset what’s entered in a text input.
·        To preset the status of radio buttons, add the code checked=”checked” to their input tags.
·        To preset the value of a textarea, print the value between the textarea tags.
·        To preset a pull-down menu, add selected=” selected” to the appropriate option.
·        PHP has the capability to allow users to define their own function. It can be any combination of letters, numbers, and the underscore, but it must begin with either a letter or the underscore.