Slide - GUI To Create a DB Table

Download Report

Transcript Slide - GUI To Create a DB Table

GUI To Create a DB Table
CS346
Fall 2010
1
Methods to create a table
• At your local server and/or remote server
– Use MySQL Console and create it interactively
– Use a batch SQL script
• Use HTML and PHP scripts with goals:
– Let user interactively define the fields
– Identical development environment on local and
remote servers
2
Establish an identical environment
• Create a user on local server with the same
<username> and <password> as your own on
remote server (cs346)
• Create a database called <username>
• See create_user_student.txt
3
Your Music collection
• Suppose you want to create a database table
my_music with 8 attributes (columns)
•
•
•
•
•
•
•
•
id
format
title
fname of artist
lname of artist
rec_label
my_notes
date_acq
4
Interaction of 3 scripts
• 12-1show_createtable.html to prompt for
– Name of table
– Number of attributes (columns)
– Then call 12-1show_fielddef.php
• 12-1do_show_fielddef.php
– Display a form for user to specify field names,
types, and length
• 12-1do_createtable.php
– Do the actual create table
5
Before running the scripts, list the tables in the
database student by running
http://127.0.0.1/student/m11/11-3db_listtables.php
See the following slide
6
7
8
9
Hmm! The message is not quite correct.
Intention is to show that the table is being
added to the database ‘student’.
Correction: remove the quotes around
“DB_NAME”. But at this point, I need to drop
the table and create it again. Let us fix the
script, upload it to cs346 latgerand test again.
Check if the table my_music has been really created in the database student
by running http://127.0.0.1/student/m11/11-3db_listtables.php
10
11
Upload the m12 directory by Fillzilla to
/var/www/students/student
Then check the tables in the user student
12
13
Note we are now in the student account in cs346 server
14
15
Note: The message is corrected to show that
the table is being added to the database
‘student’.
My correction: remove the quotes around
“DB_NAME”
16
17
18