Accessing Databases

Download Report

Transcript Accessing Databases

Accessing Databases
By Brian Hall
Database History

Originally paper and books
Drawers and drawers of paper and ink
 Difficult to have a back up copy
 If building destroyed then information
destroyed
 Pain in the neck to transfer information across
miles
 This can be very bad

History (contd.)
First ‘relational’ products appeared late
70’s early 80’s
 Relational model basically means that the
information is represented in rows and
columns (to the user)

Relational Example
FName
LName
Age
Classification
John
Doe
19
Sophomore
Jane
Doe
22
Senior
How does SQL tie in?
SQL is the language that helps
manipulate, design, and access your
database. With it you can:
SELECT
INSERT
UPDATE
DELETE
information
Development Languages
1.
2.
3.
Visual Basic 6.0
PHP
COBOL
Visual Basic 6.0
Pros
 Much support
available
 Widely used
 Many communities
Cons
 Runs solely on
Microsoft platforms
VB6 Connection Code
Dim Database as DAO.Database
Dim Recordset as DAO.Recordset
Set Database = OpenDatabase(<databaselocation>)
StrSql = "SELECT Stu_FName ,Stu_LName FROM Student"
Set R1 = Database.OpenRecordset(StrSql)
Do Until Recordset.EOF
cmbName.AddItem (Recordset!Stu_FName + " " +_
Recordset!Stu_LName)
Recordset.MoveNext
Loop
PHP
Pros
Cons
 Fast and efficient
 VERY loosely typed
 Runs on server not on  Constantly changing
client machine
 Not platform specific
 Not browser specific
 Small learning curve
PHP Connection Code
<html>
<body>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$result = mysql_query("SELECT * FROM employees",$db);
echo "<table border=1>\n";
echo "<tr><td>Name</td><td>Position</tr>\n";
while ($myrow = mysql_fetch_row($result))
{ printf("<tr><td>%s %s</td><td>%s</td></tr>\n", $myrow[1], $myrow[2],
$myrow[3]);
}
echo "</table>\n";
?>
</body>
</html>
COBOL
Pros
 Generally Easy to use
 Easy to teach
 Text parse and test
functions built in
Cons
 Verbose language
 Cannot directly define
data types
COBOL Connection Code
Need to include
EXEC SQL INCLUDE SQLCA END-EXEC.
And the compiler will automatically add…
THIS
01 SQLCA.
05 SQLCAID PIC X(8).
05 SQLCABC PIC S9(9) BINARY.
05 SQLCODE PIC S9(9) BINARY.
05 SQLERRM.
49 SQLERRML PIC S9(4) BINARY.
49 SQLERRMC PIC X(70).
05 SQLERRP PIC X(8).
05 SQLERRD OCCURS 6 TIMES PIC S9(9) BINARY.
05 SQLWARN.
10 SQLWARN0 PIC X.
10 SQLWARN1 PIC X.
10 SQLWARN2 PIC X.
10 SQLWARN3 PIC X.
10 SQLWARN4 PIC X.
10 SQLWARN5 PIC X.
10 SQLWARN6 PIC X.
10 SQLWARN7 PIC X.
10 SQLWARN8 PIC X.
10 SQLWARN9 PIC X.
10 SQLWARNA PIC X.
05 SQLSTATE PIC X(5).
Contributions

Research


Term Paper (Rough/Final)


Brian Hall
Presentation (Rough/Final)


Brian Hall
Brian Hall
Staying Up All Night to finish this dang
thing….

Brian
Future Endeavors
Research further into each language and
actual language connection strings (more
in depth)
 Research further into SQL and built in
functionality
 Research further into local and server
based server suppliers (DB2, MySQL,
SQL2000, etc.)

Bibliography
Database Book
“PHP/MySQL Tutorial”; Graeme Merall;
http://webmonkey.wired.com/webmonkey/programming/php/tutorials/tutorial
4.html
“PHP Pros and Cons”; http://c2.com/cgi/wiki?PhpProsAndCons
“The Cobol Language”;
http://www.cs.vu.nl/~eliens/documents/libero/lrlang6.htm
“Defining the SQL Communications Area in COBOL applications that use SQL”;
http://publib.boulder.ibm.com/html/as400/v4r5/ic2924/index.htm?info/db2/rz
ajpmst43.htm
“An Introduction to Database Systems”, 8th Ed.; CJ Date; © 2004 Pearson
Education, Inc.