Upload
ralf-harmon
View
223
Download
0
Embed Size (px)
DESCRIPTION
Classes Tables: one entry per section of each course offered Courses Table: one entry per class that’s ever offered
Citation preview
Courses
Num Name Desc
Record
Field
Table
Table
Credits
“PROJECT” “SELECT”
Operators on Tables
Classes Tables: one entry per section of each course offered
Courses Table: one entry per class that’s ever offered
Database
Application logic(system
programminglanguage)
SQL
Record at a time processing
SQL Example
select coursenumber, isIEMP from course where coursenumber = 603;
A Join Operation
select coursenumber, coursename from course, class where course.courseid=class.xrefcourseid and class.yearoffered=1999 and class.termoffered='FALL';
The Web Interface
Websites that Serve FilesWeb browser
Web server File system2. filename
3. File contents
1. URL 4. HTML
Dynamically Generated PagesWeb browser
Web server File system
Script interpreter
4. File contents 5. HTML
2. filename
3. File contents
1. URL 6. HTML
<html> <head> <title>PHP Exercise</title> </head> <body> <? echo "<b>Your Query has returned 7 hits.</b>"; echo "<p><table border=1>"; for ($i=0;$i<7;$i++) { echo "<tr><td>"; echo "column 1 row $i ", "</td><td>"; echo "column 2 row $i", "</td></tr>"; } echo "</table></p>"; ?></body></html>
RUN
Database-Generated PagesWeb browser
Web server
DBMS
File system
Script interpreter5. SQL statement
6. Query result
4. File contents 7. HTML
2. filename
3. File contents
1. URL 8. HTML
<?mysql_connect("ebola.si.umich.edu:3306","webuser","");$result = mysql("presnick", "SELECT
coursenumber,coursename FROM course,class WHERE course.courseid=class.xrefcourseid AND class.yearoffered='1997' ORDER BY coursenumber");
$num = mysql_numrows($result);
echo "<b>Your Query has returned $num hits.</b>";echo "<p><table border=1>";for ($i=0;$i<$num;$i++){
echo "<tr><td>";echo
mysql_result($result,$i,"coursenumber")."</td><td>";echo
mysql_result($result,$i,"coursename")."</td></tr>";}
mysql_close();echo "</table></p>";
?>RUN
<html><head><title>PHP Exercise</title></head>
<body><h1>Class information of 1997 from presnick's database</h1>
<b>Your Query has returned 40 hits.</b><p><table border=1><tr><td>501</td><td>Use of Information</td></tr><tr><td>502</td><td>Choice and Learning</td></tr><tr><td>511</td><td>Technology in Design: Methods and Means</td>...</tr></table></p></body></html>
COUNT Query
select count(*) as total from course where coursenumber= 603;
GROUP By Query
select isarm, count(*) from course group by isarm;
XML: Data + Structure<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="results.xsl"?><result>
<row><NUM> 501 </NUM><NAME> Use of Information </NAME></row>
<row><NUM> 502 </NUM><NAME> Choice and Learning </NAME></row>
<row><NUM> 511 </NUM><NAME> Technology in Design: Methods and Means </NAME></row></result>
XSL: Presentation<table border="1"><xsl:for-each select="result/row"> <TR> <TD><xsl:value-of select="NUM"/></TD> <TD><xsl:value-of select="NAME"/></TD> </TR></xsl:for-each></table>RUN
XML ProcessingWeb browser
Web server
DBMS
File system
Script interpreter5. SQL statement
6. Query result
4. File contents 7. XML
2. filename
3. File contents
1. URL 8. XML & XSL
Preprocessor
HTML Rendering Engine
HTML
Generating XML…$num = mysql_numrows($result);for ($i=0;$i<$num;$i++){echo "<row>";echo "<NUM> ”. mysql_result($result,$i,"coursenumber")." </NUM>";echo "<NAME> ". mysql_result($result,$i,"coursename")." </NAME>";echo "</row>";}… RUN
Referral Today
ACME
AIDS Consortium
Linda’s Meals
DB
Referral Tomorrow
ACME
AIDS Consortium
Linda’s Meals
DBXML + formatting
Referral Eventually
ACME
AIDS Consortium
Linda’s Meals
DB
XML
XML
DB
DB
AIDS Consortium Form
Client Name:<INPUT id="idfillinbox" NAME=CLIENT_FULL_NAME STYLE="width:3.125in"></INPUT>
D.O.B.<INPUT id="idfillinbox" NAME=DATE_OF_BIRTH STYLE="width:1.625in"></INPUT>
Sex: Male<INPUT ID="idlineradio" VALUE="1" TYPE="radio" NAME="SEX">
Female<INPUT ID="idlineradio" VALUE="2" TYPE="radio" NAME="SEX">
Linda’s Meals Form
Client Name:<INPUT id="idfillinbox" NAME=CLIENT_FULL_NAME STYLE="width:3.75 in"></INPUT>
SSN:<INPUT id="idfillinbox" NAME=CLIENT_SSN STYLE="width:2 in"></INPUT>