CS146 Database Systems - PowerPoint PPT Presentation

About This Presentation
Title:

CS146 Database Systems

Description:

SQL, MySQL, etc... In-class and homework Programming ... Apply for a mysql account ... Useful package (Apache, MySql,PhP): http://www.easyphp.org/ Where ? ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 24
Provided by: seas6
Category:

less

Transcript and Presenter's Notes

Title: CS146 Database Systems


1
CS146 Database Systems Team Projects
  • Spring 2009

2
Introduction
  • Lab instructor
  • Darby Thompson
  • darbyt_at_gwu.edu
  • Office Hours By Appt
  • Lab page will be linked from the course page
  • http//www.seas.gwu.edu/bhagiweb/cs146/

3
What do I expect from students in the lab
  • WID Writing assignments - go to the WID TA if you
    have questions
  • Programming assignments
  • Submit using Blackboard
  • Due at 11.59pm
  • Dont be late!

4
What do I expect from students in the lab
  • Grading policy for programming assignments
  • Queries with syntactic errors will not be
    considered.
  • Run your queries before sending them
  • If the query works, it is likely you will get all
    the points for it

5
What do I expect from students in the lab
  • I will explain everything in the lab. Be there
    dont fall asleep!
  • You are expected to play with the tools on your
    own and learn at least enough to do the project.
  • Email me to set up appointments - Ill probably
    need more than 1 hour notice!
  • Start early

6
What do I expect from students in the lab
  • Teamwork! You will be working on long term team
    projects.
  • Communicate with your teammates and let them know
    if youre having problems
  • Communicate with me and let me know if youre
    having problems

7
Lab Outline
  • What we will do
  • SQL, MySQL, etc
  • In-class and homework Programming Assignments
  • Team Project
  • PHP, JDBC
  • Ethics debates/discussions (ideas?)
  • Lectures/lab swap

8
Databases
  • What do you already know about databases?
    Keywords? Tools/Applications?
  • Any idea what SQL stands for?

9
Databases
  • Standard Query Language

10
Apply for a mysql account
  • Send an email NOW to support_at_ticket.seas.gwu.edu
    and request a MySQL account. Mention that you are
    taking CS146
  • You will need the account for next lab (in class
    exercises)

11
Php
  • Official site www.php.net
  • PhP manual http//www.php.net/manual/en/index.php
  • Useful package (Apache, MySql,PhP)
    http//www.easyphp.org/

12
Where ?
  • Ssh into cobweb.seas.gwu.edu and put your php
    files
  • Access them via http//www.student.seas.gwu.edu/y
    ourusername/filename.php

13
How ?
  • You can use a basic text editing program to write
    php files, and CyberDuck to move files onto
    cobweb
  • Additionally can use X11 Terminal to copy a file
    from your computer to the server using the
    following command
  • scp filename.php username_at_cobweb.seas.gwu.edupubl
    ic_html/

14
What is PhP
  • PHP is a widely-used general-purpose scripting
    language that is especially suited for Web
    development and can be embedded into HTML
    (www.php.net)
  • Server scripting language (Javascript is a client
    side scripting language)
  • If you know C, you will learn PhP in no time.

15
Hello World!
  • Index.php
  • lthtmlgt ltheadgt  lttitlegtPHP Testlt/titlegt lt/headgt
     ltbodygt lt?php echo 'ltpgtHello Worldlt/pgt'
    ?gtlt/bodygtlt/htmlgt
  • Output
  • lthtmlgt
  • ltheadgt
  • lttitlegtPHP Testlt/titlegt
  • lt/headgt
  • ltbodygt
  • ltpgtHello Worldlt/pgt
  • lt/bodygt
  • lt/htmlgt

16
Basics
  • Use echo for printing
  • Variables start with sign
  • Do not have to explicitly assign them a type
    (like int, array, etc.)
  • . (dot) concatenates 2 strings. Ex
    aHellobWorld echo a. .b displays
    Hello World

17
Accesing databases from PhP
  • lthtmlgt
  •  ltheadgt
  •   lttitlegtPHP Testlt/titlegt
  •  lt/headgt
  •  ltbodygt
  • lt?php
  • linkmysql_connect("localhost",username",passwo
    rd") or
  • die("Error connecting to the database
    server".mysql_error()."ltbrgt\n")
  • mysql_select_db(username") or
  • die("Error selecting the database".mysql_error
    ()."ltbrgt\n")
  • ?gt
  • lt?php
  • sql "SELECT name, id FROM employees"
  • resultmysql_query(sql)
  • while(list(name,id) mysql_fetch_array(result)
    )
  • echo "ltpgt".name." ".id

18
Arrays
  • A mapping between keys and values. Example
  • lt?phparr array("foo" gt "bar", 12 gt
    true)echo arr"foo" // barecho arr12   
    // 1
  • foreach (arr as key gt value)
  • echo key.key echo value,value.ltBRgt
  • ?gt

19
Get and Post
  • _GETvariablename the variable is appended
    to the http address, and is transmited in the
    same stream. Ex http//www.somesite.com/index.php
    ?a1bx. Easy to bookmark
  • _POSTvariablename a new stream is created,
    and all the post variables are transmited in this
    stresm. The http address is clean (no bookmarks)

20
Get variables from forms
Action.php ltHTMLgt ltBODYgt lt?php echo "Your name is
"._POST"name"." and you are "._POST"age"."
years old"?gt lt/BODYgt lt/HTMLgt
  • getName.html
  • ltHTMLgt
  • ltBODYgt
  • ltform action"action.php" method"post"gt
  • ltpgtYour name ltinput type"text" name"name"
    /gtlt/pgt
  • ltpgtYour age ltinput type"text" name"age"
    /gtlt/pgt
  • ltpgtltinput type"submit" value"Submit"/gtlt/pgt
  • lt/formgt
  • lt/BODYgt
  • lt/HTMLgt

21
Some usefull global variables
  • _SESSION -An associative array containing
    session variables available to the current
    script.
  • _SERVERPHP_SELF- The filename of the
    currently executing script, relative to the
    document root. For instance, _SERVER'PHP_SELF'
    in a script at the address http//example.com/test
    .php/foo.bar would be /test.php/foo.bar.
  • _SERVER'SERVER_NAME'- The name of the server
    host under which the current script is executing.
    If the script is running on a virtual host, this
    will be the value defined for that virtual host.
  • __LINE__The current line number of the file.
  • __FILE__The full path and filename of the file.
    If used inside an include, the name of the
    included file is returned.

22
Session
  • HTTP is stateless
  • Simulates a statefull connection. Maintains
    records on the server side until the browser is
    closed.
  • session_start()
  • _SESSIONfoobar
  • _SESSIONabc
  • Allows to build a shoping cart

23
Includes
  • header.php
  • lthtmlgt
  •  ltheadgt
  •   lttitlegtPHP Testlt/titlegt
  •  lt/headgt
  •  ltbodygt
  • ltTABLE width"800" cellpadding"4"
    cellspacing"0" align"center" border"0"gt
  • ltTRgt
  • ltTD width'100'gt
  • footer.php
  • lt/TDgt
  • lt/TRgt
  • lt/TABLEgt
  • lt/bodygt
  • lt/htmlgt
  • index.php
  • lt?php
  • include header.php
Write a Comment
User Comments (0)
About PowerShow.com