1
|
- Week 7
- LBSC 690
- Information Technology
|
2
|
- Questions
- E-R Modeling
- PHP
- Mythical person-month
- Midterm review
|
3
|
- Databases are a good choice when you have
- Lots of data
- A problem that contains inherent relationships
- Design before you implement
- This is just another type of programming
- The mythical person-month applies!
- Join is the most important concept
- Project and restrict just remove undesired stuff
|
4
|
- What questions must you answer?
- What data is needed to generate the answers?
- Entities
- Attributes of those entities
- Relationships
- Nature of those relationships
- How will the user interact with the system?
- Relating the question to the available data
- Expressing the answer in a useful form
|
5
|
|
6
|
- Entities
- Types
- Subtypes (disjoint / overlapping)
- Attributes
- Identifier
- Relationships
- Cardinality
- Existence
- Degree
|
7
|
- Pick a primary key for each entity
- Build the tables
- One per entity
- Plus one per M:M relationship
- Choose terse but memorable table and field names
- Check for parsimonious representation
- Relational “normalization”
- Redundant storage of computable values
- Implement using a DBMS
|
8
|
- 1NF: Single-valued indivisible (atomic) attributes
- Split “Doug Oard” to two attributes as (“DougR=
21;,
“Oard”)
- Model M:M implement-role relationship with a table
- 2NF: Attributes depend on complete primary key
- (id, impl-role, name)->(id, name)+(id, impl-role)
- 3NF: Attributes depend directly on primary key
- (id, addr, city, state, zip)->(id, addr, zip)+(zip, city, state)=
- 4NF: Divide independent M:M tables
- (id, role, courses) -> (id, role) + (id, courses)
- 5NF: Don’t enumerate derivable combinations
|
9
|
- Persons: id, fname, lname, userid, password
- Contacts: id, ctype, cstring
- Ctlabels: ctype, string
- Students: id, team, mrole
- Iroles: id, irole
- Rlabels: role, string
- Projects: team, client, pstring
|
10
|
- Static: Written in a markup language
- Dynamic: Generated using a program
- Common Gateway Interface [Perl] (.cgi)
- Java servlets
- Dynamic: Generated from a database
- Cold Fusion (.cfm)
- PHP (.php)
|
11
|
- Remote access to a database
- Client does not need the database software
- Serve rapidly changing information
- e.g., Airline reservation systems
- Provide multiple “access points”
- By subject, by date, by author, …
- Record user responses in the database
|
12
|
- Benefits
- Multiple views
- Data reuse
- Scalable
- Access control
- Costs
- Formal modeling
- Complex (learn, design, implement, debug)
- Brittle (relies on multiple communicating servers)
- Not crawlable
|
13
|
- Brittle
- Depends on multiple servers
- Complex
- Learning, design, implementation, debugging
- Formally modeled
|
14
|
|
15
|
- Displays database content on Web pages
- Not very useful for changing database content
- Drag-and-drop design in Microsoft Access
- “Reports” are designed for printing
- “Pages” are designed for the Web
- Requirements:
- Microsoft Web Server (not Apache)
- IE 5 or higher Web browser (not Firefox)
- “Office Web Components” on client machine
- IE 7 fails gracelessly without them!
|
16
|
|
17
|
|
18
|
- You need three systems on the same server:
- PHP (programming language)
- MySQL (DBMS)
- Apache (Web server)
- WampServer (for PC)
- OTAL (Sun Unix) supports Web deployment
- Requires a text editor (e.g., emacs) or FTP
|
19
|
- ----- HTML stuff -----
- <?php
- ----- PHP stuff -----
- ?>
- ----- HTML stuff -----
- http://---URL stuff---/xxxxx.php
|
20
|
- Download and install
- From http://www.en.wampserver.com/
- Make sure the server is working
- Point a Web browser at http://localhost/
- Select phpinfo.php
- Error reporting on? =
MySQL
listed?
- Test the connection to MySQL
- Run mysql_test.php (“Resource id #2” indicates ok)
-
<?php
- &nbs=
p;
echo mysql_connect(‘localhost’, ‘root̵=
7;,
‘’);
-
?>
|
21
|
- On WAMP:
- $dbc=3Dmysql_connect (‘localhost’, ‘userid’,
‘password’);
- On OTAL:
- $dbc=3Dmysql_connect(‘:/export/software/otal/mysql/run/mysqld.=
sock’,
- ‘userid’, ‘password’);
|
22
|
- “root” user creates database + grants permissions
- Using the WAMP console (or mysql –u root –p)
- root has no initial password; just hit <enter> when asked
- By the system administrator on OTAL (otal.umd.edu)
-
CREATE DATABASE project;
-
GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, =
DROP
ON project.* TO ‘foo’@’localhost’ IDENTIFIE=
D BY
‘bar’;
-
FLUSH PRIVILEGES;
- Start mysql
- MySQL console for WAMP, ssh for OTAL
- &nbs=
p; &=
nbsp; &nbs=
p; &=
nbsp; &nbs=
p; &=
nbsp; &nbs=
p;
mysql –u foo –p bar
- Connect to your database
|
23
|
- CREATE TABLE contacts (
- ckey MEDIUMINT UNSIGN=
ED NOT
NULL AUTO_INCREMENT,
- id MEDIUMINT UNSIGNE=
D NOT
NULL,
- ctype SMALLINT UNSIGN=
ED NOT
NULL,
- cstring VARCHAR(40) N=
OT
NULL,
- FOREIGN KEY (id) REFE=
RENCES
persons(id) ON DELETE CASCADE,
- FOREIGN KEY (ctype)
REFERENCES ctlabels(ctype) ON DELETE RESTRICT,
- PRIMARY KEY (ckey)
- ) ENGINE=3DINNODB;
- To delete: DROP TABLE contacts;
|
24
|
- INSERT INTO ctlabels
- (string) VALUES
- ('primary email'),
- ('alternate email'),<=
/li>
- ('home phone'),
- ('cell phone'),
- ('work phone'),
- ('AOL IM'),
- ('Yahoo Chat'),
- ('MSN Messenger'),
- (‘other’)=
;
- To empty a table: DELETE FROM ctlabels;
|
25
|
- SHOW DATABASES;
- SHOW TABLES;
- DESCRIBE tablename;
- SELECT * FROM tablename;
|
26
|
|
27
|
|
28
|
- SELECT Company.CompanyName, Company.CompanyPhone, Flight.Origin,
Flight.DepartureTime
- FROM Flight,Company
- WHERE Flight.CompanyName=3DCompany.CompanyName
- AND
Flight.AvailableSeats>3;
|
29
|
- Sequential
- {…; …;…;}
- Semicolons are required at the end of every statement
- Conditional
- if (3=3D=3Di) {…} else {…}
- Loop
- for ($i=3D0; $i<10; $i++) {…}
- while ($row=3Dmysql_fetch_array(…)) {…}
- foreach ($array as $key =3D> $value) {…}
- Braces are optional around a single statement
|
30
|
- Name starts with a $
- Case sensitive (assume everything could be!)
- Hold a value
- Number (integer, float)
- String (double quotes, \ escape character)
- TRUE, FLASE
- NULL
- Need not be declared (automatically “cast”)
|
31
|
- Arithmetic operators
- Logical operators
- < <=3D =3D=3D !=3D >=3D > && || !
- String operator
|
32
|
- A set of key-element pairs
- $days =3D array(“Jan”->31, “Feb”=3D>2=
8,
…);
- $months =3D explode(“/”,
“Jan/Feb/Mar/…/Dec”);
- $_POST
- Each element is accessed by the key
- {$days[“Jan”]}
- $months[0];
|
33
|
- Declaration
- function multiply($a, $b=3D3){return $a*$b;}
- Invoking a method
- All variables in a function have only local scope
- Unless declared as global in the function
|
34
|
- <form action=3D“formResponseDemo.php”,
method=3D“post”>
- email: <input type=3D“text”, name=3D“emailR=
21;, value=3D“<?php
echo $email ?>”, size=3D30 />
- <input type=3D“radio”, name=3D“sure”,
value=3D“yes” /> Yes
- <input type=3D“radio”, name=3D“sure”,
value=3D“no” /> No
- <input type=3D“submit”, name=3D“submit”,
value=3D“Submit” />
- <input type=3D“hidden”, name=3D“submitted̶=
1;,
value=3D“TRUE” />
- </form>
- if (isset($_POST[“submitted”])) {
- echo “Your email address is $email.”;
- } else {
- echo “Error: page reached without proper form submission!R=
21;;
- }
|
35
|
|
36
|
|
37
|
|
38
|
|
39
|
|
40
|
|
41
|
|
42
|
- Google Maps
- Google Suggest
- http://www.google.com/webhp?complete=3D1&hl=3Den
- Sajax Tables
- http://labs.revision10.com/?p=3D5
- Sajax
- http://www.modernmethod.com/sajax/
|
43
|
- Why is software development different from manufacturing car?
- If it would take one person three months, why does it take four peop=
le
SIX months?
|
44
|
- Sequential constraints
- Communication
- Training
|
45
|
- Rules of thumb
- 1/3 specification
- 1/6 coding
- 1/2 test planning, testing, and fixing!
- Add time for coding to learn as you go, but don’t take time aw=
ay
from the other parts!
- Reread the section on “gutless estimating” if you are
tempted
|
46
|
|
47
|
- 1 hour and 15 minutes
- Second half of class: project team meetings
- Quiz/homework should be good preparation
- A variety of question types
- Some questions will require computer use
- Lots of prior exams are available
- Some have solutions available
- Open book/notes/Internet/mind/…
- Just don’t get help from another person
|
48
|
- Hardware
- Types of hardware
- Storage hierarchy
- Moore’s law
- Software
- Types of software
- Types of interfaces
|
49
|
- Types of Networks
- LAN, WAN, Internet, Wireless
- Packet Switching
- Ethernet, routers, routing tables
- Layered Architecture and protocols
- TCP/UDP
- IP address/domain name
|
50
|
|
51
|
|
52
|
- Programming languages
- Machines require specific instructions
- Humans require high-level abstraction
- Control structures
- Sequential execution
- Conditional
- Iteration
- Javascript
|
53
|
- Structured information
- Field->record->table->database
- Primary key
- Normalized tables (relations)
- Remove redundancy, inconsistency, error
- Easy update, search
- Join links tables together
- Access provides visual operations
|
54
|
- Microsoft “Data Access Pages”
- Server-side database integration
- Ajax
- Mythical person-month
|