Final Exam Guide PHP NOTE: PHP CODE WILL BE BLUE, HTML IS BLACK EXAMPLE <?php session_start(); //need this before declaring a session global. echo " You.

Slides:



Advertisements
Similar presentations
LIS651 lecture 3 taming PHP Thomas Krichel
Advertisements

LIS651 lecture 3 taming PHP Thomas Krichel
Advanced SQL (part 1) CS263 Lecture 7.
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
Keys, Referential Integrity and PHP One to Many on the Web.
COMP 3715 Spring 05. Working with data in a DBMS Any database system must allow user to  Define data Relations Attributes Constraints  Manipulate data.
Accounting 6500 Relational Databases: Accounting Applications Introduction to Normalization.
1 Creating a Non-Conditional List A- What are you going to do? You will “list” “all of the records” in a database. (it means you will not use any condition!)
Intermediate PHP & MySQL
Tutorial 5 Multi-table queries. Tutorial 5 objectives Displaying Data from Multiple Tables –[ ]Write SELECT statements to access data from more than one.
SQL Tutorials To understand some of the topics please analyze the following tutorials: The following tutorials will help:
PHP & MySQL Mahak Arora Vivek Bangera. Outline How PHP works Basic scripting in PHP Forms in PHP(GET & POST Variables) SQL basics PHP and MySQL connection.
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
Creating Databases for Web Applications SQL Select extras Listing [names of] tables generalized display of recordset simple password handling php and other.
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
C H A P T E R 4 Designing Database E-Commerce Hassanin M. Al-Barhamtoshy
SQL in Action Amit Bhawnani & Nimesh Shah. Basic Structure SQL is based on set and relational operations with certain modifications and enhancements A.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Week 9 PHP Cookies and Session Introduction to JavaScript.
SHOPPING CARTS CHAPTER 19. E-COMMERCE Typically, an e-commerce site will have public pages and admin pages.
PHP meets MySQL.
Basic SQL. Implementation Schemes: Once we have a set of relation schemes, we can translate them into implementation schemes. We use to express implementation.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Introduction to MySQL Lab no. 10 Advance Database Management System.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
SQL 101 for Web Developers 14 November What is a database and why have one? Tables, relationships, normalization SQL – What SQL is and isn’t – CRUD:
PHP and MySQL CS How Web Site Architectures Work  User’s browser sends HTTP request.  The request may be a form where the action is to call PHP.
CSC 405: Web Application And Engineering II9.1 Web programming using PHP What have we learnt? What have we learnt? Sending s using PHP Sending s.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Database Fundamentals Lecture 4 Useful website for MySQL download language.com/workshops/Default.asp ?workshop=21.
Creating Databases for web applications [Complete presentations] More SQL Class time: discuss final projects. Do posting if you have not done it.
Creating databases for web applications Library. New example: student database. Homework: Complete class example. Catch up on source postings. Do creation.
Creating a dynamic search form with database paging Tony Rogerson SQL Server MVP Torver Computer Consultants.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
SQL LANGUAGE and Relational Data Model TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
PHP getting data from a MySQL database. Replacing XML as data source with MySQL Previously we obtained the data about the training session from an XML.
Creating A Database Driven Website 1.Setting Up Your Web Server 2.Creating a Database 3.Creating a Webpage to Display Information From a Database 4.Creating.
INTRODUCTION TO SQL Chapter SELECT * FROM teacher WHERE INSTR (subject_id, ‘&1’)= 4 AND LOWER (subject_id) LIKE ‘HST%’ ; When prompted for the.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
Understanding Databases Lesson 6. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Relational Database Concepts Understand relational.
PHP Database Pemrograman Internet. PHP MySQL Database With PHP, you can connect to and manipulate databases. MySQL is the most popular database system.
CSC 405: Web Application Engineering II9.1 Web programming using PHP What have we learnt? What have we learnt? Sending s using PHP Sending s.
CHAPTER 10 PHP MySQL Database
PHP Session ISYS 475. Session The web server starts a session when a visitor visiting your web site and assigns a unique id, the session id for the session.
Sessions Brendan Knight A visitor accessing your web site is assigned a unique id. This id links to specific data that remains on the server. Sessions.
Class11 Introduction to relational databases and MySQL MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University.
IS6146 Databases for Management Information Systems Lecture 4: SQL IV – SQL Functions and Procedures Rob Gleasure robgleasure.com.
LINQ to DATABASE-2.  Creating the BooksDataContext  The code combines data from the three tables in the Books database and displays the relationships.
Working With Database Library And Helpers. Connecting to your Database First you need to set parameters in you database.php file residing in config folder.
Exam 2 Review. SQL – Create Table REMEMBER!! – Create table mxws.Contact ( ContactID INT(10) NOT NULL,.., primary key (contactID));
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
Standard language for querying and manipulating data Structured Query Language Many standards out there: ANSI SQL, SQL92 (a.k.a. SQL2), SQL99 (a.k.a. SQL3),
The Booktopia Database
Order Database – ER Diagram
How to: SQL By: Sam Loch.
More SQL: Complex Queries,
CS3220 Web and Internet Programming More SQL
Structured Query Language
Rob Gleasure robgleasure.com
Introduction to Web programming
Structured Query Language – The Basics
ISC440: Web Programming 2 Server-side Scripting PHP 3
Rob Gleasure robgleasure.com
Structured Query Language – The Fundamentals
ER Diagram Master How to use this template
Introduction to Web programming
Presentation transcript:

Final Exam Guide PHP NOTE: PHP CODE WILL BE BLUE, HTML IS BLACK EXAMPLE <?php session_start(); //need this before declaring a session global. echo " You are on page ".$_SERVER['PHP_SELF']." "; if($_SESSION['last_page']) { echo " The page you last visited is ".$_SESSION['last_page']; } $_SESSION['last_page'] = $_SERVER['PHP_SELF']; ?> include('sql_file_with_login_info'); //$sqluser, $sqlpw, $mydb are defined in this file. $conn = new mysqli('localhost', $sqluser, $sqlpw, $mydb); if($conn->connect_error) { die("Connection Failed: ".$conn->connect_error); //If errored. } $query = "SELECT * FROM table"; //All queries go here, flip the paper for examples. $result = $conn->query($query); if($result->num_rows > 0) { //if $result has any data in the array. while($row = $result->fetch_assoc()) { echo $row['table_column'] } //creates $conn object to make a SQL connection //creates $result object array with $query data. //gets current page file name //sets the global session variable to the current page, so when switching pages you can determine the last page. NOTE: PHP CODE WILL BE BLUE, HTML IS BLACK EXAMPLE <?php if($_POST['inputname'] { //if the POST global variable exists. $user = $_POST['inputname']; //assign POST variable to variable echo "Hello ".$user.", Welcome to this page!"; }else{ ?> //suspend PHP, for easier HTML form creation //need a submit button to reload the page <?php } //this is required to end the IF..ELSE loop prior to the form HTML ?> //action should be a PHP page //variable name for POST['inputname'] $_SESSION['custom_attribute'] = global session variable. $_POST['send_to_server'] = incoming submitted form data. $_GET['get_from_server'] = check for variable in URL Example of $_GET if($_GET['variable'] { echo $_GET['variable']; } session_destroy(); //deletes all session variables LOOPS while( condition is true, or variable exists ) { //perform actions until condition false } for ($i = 1; $i <= 10; $i++) { //perfom loop 10 times } 3 NORMAL FORM //all take requirements from previous 1 - data need to be economy, smallest format 2 - every non-primary attribute needs to be dependent on the key (functional dependency) 3 - transitivity - every value is non-transitive or dependent on a super key. BNCF "Boyce-Codd Normal Form" or 3.5NF - slightly stronger and fixes anomalies with 3NF MVC - "Model" - "View" - "Controller" -SQL is the Model. -HTML is the View. -PHP is the Controller. //put your own name on your test. UML ER books authors customersbranches CheckoutCarry Visit Wrote title date isbn first last bday locname id (1,0) one to many (0,1) many to one (1,1) one to one RELATIONSHIPS Author id INT First VARCHAR Last VARCHAR bday DATE PRIMARY Wrote author_id book_id Author.id Book.id Book id INT title VARCHAR isbn INT pub DATE PRIMARY Customer id INT name VARCHAR PRIMARY Borrow book_id customer_id Customer.id Book.id

SQL Final Exam Guide create table Movie ( mID int PRIMARY KEY, title VARCHAR(200), year int, director VARCHAR(200), UNIQUE (title,year) ); create table Reviewer ( rID int PRIMARY KEY, name VARCHAR(200), ); create table Rating ( rID int, mID int, stars int NOT NULL, ratingDate date, UNIQUE(rID,mID,ratingDate), FOREIGN KEY(rID) REFERENCES Reviewer(rID) ON UPDATE CASCADE ON DELETE SET NULL, FOREIGN KEY(mID) REFERENCES Movie(mID) ON DELETE CASCADE ); //put your own name on your test. MOST COMMON type of join is INNER JOIN, returns all rows from multiple tables where the join condition is met. EX. SELECT o.OrderID, o.OrderID, c.CustomerName FROM Orders o INNER JOIN Customers c ON o.CustomerID = c.CustomerID; REPLACE INNER JOIN WITH FOR SPECIFIC JOIN FEATURES. LEFT JOIN - returns all rows from left table, matching rows in the right table. RIGHT JOIN - returns all rows from right table, matching rows in the left table. FULL OUTER JOIN - returns all rows from both tables. EX. SELECT e.EmployeeID, o.OrdersID FROM Employees e LEFT JOIN Orders o ON e.EmployeeID = o.EmployeeID WHERE e.EmployeeID > 8 ORDER BY e.EmployeeID DESC; //this returns all employees with an ID greater than 8 and all their ORDER IDs from the Orders table SELECT * FROM Products; SELECT SUM(Quantity) AS "Quantity of Sum" FROM OrderDetails; SELECT DISTINCT ProductID FROM OrderDetails WHERE ProductID GROUP BY ProductID; SELECT DISTINCT CustomerName,Country FROM Customers WHERE Country != "USA"; SELECT DISTINCT CurstomerName, Address FROM Customers WHERE Address LIKE("%PO%"); SELECT CategoryID, max(Price) AS "Max Price", min(Price) AS "Min Price" FROM Products WHERE CategoryID GROUP BY CategoryID; SELECT ProductName, FROM Products WHERE CategoryID = (SELECT CategoryID FROM Categories WHERE CategoryName = "Seafood"); SELECT ProductID FROM OrderDetails WHERE OrderID IN (SELECT OrderID FROM Orders WHERE ShipperID = 3) GROUP BY ProductID); To speed up databases there is an optimizer built into databases, also you can use INDEX keys in the database. UPDATE Suppliers SET Country = "United Kingdom" WHERE Country = "UK";