Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Dr. Alin Dobra UFID: 7234-9479 Lin Qi Due: Nov. 11st 2010 So far, my work meets all requirements of conceptual design, please check.
1 General
1.1 Project description
To implement a web based photo application that allows the posting of photographs together with social network facilities (to be described shortly). The information behind the application has to be stored in a DBMS and the web interface has to interact with the database to extract/update the information.
2 Conceptual Design
2.1 Structure
Users (user_id, user_name, real_name, age, location, profile, group, contacts) Picture( picture_id, pname, user_id, description) Comment( comment_id, type, comm_user_id, user_id, picture_id, content) Group( group_id, group_name, creator_id)
2.2 Tables
1. Table Users Table Number Table Description Field user_id user_name real_name age location profile group contacts 1 Type int(20) varchar(30) varchar(50) int(8) text text varchar(30) text not null not null null null null null null null Table name Index primary key Users Note To identify users, auto_increment username Real name of a user Age of a user location User profile User belongs to which group Contacts information of a user Containing user information
2. Table Picture Table Number Table Description Field picture_id pname user_id description 2 Type int(20) varchar(30) int(20) text not null not null not null null Table name Index primary key Picture Note To identify pictures, auto_increment Picture name Uploaded by which user Picture description Containing picture information
3. Table Comment Table Number Table Description Field comment_id type comm_user_id user_id picture_id content 3 Type int(20) varchar(10) int(20) int(20) int(20) text not null not null not null null null null
2
Comment Note To identify comments, auto_increment Identify comments on user / pictures Uploaded by which user Comment on which user Comment on which picture Comment content
4. Table Comment Table Number Table Description Field group_id group_name creator_id 4 Type int(20) varchar(30) int(20) not null not null not null Table name Index primary key Group Note To identify groups, auto_increment Group name Created by which user Storing groups information
user_name
age user_id
Users
location
Add_pic
Picture
description
Comment Group
group_id comm_user_id creator_id group_name content
type
user_id picture_id
3 SQL Codes
3.1 Starting up the database "DBMS_project"
1) Create database named "DBMS_project":
CREATE DATABASE `DBMS_project` ;
4 PHP Code
4.1 PHP website code
<?php $conn = mysql_connect("localhost","root",""); if (!$conn) { die('Could not connect to the server ' . mysql_error()); } mysql_select_db("dbms_project"); //select database $result = mysql_query("select * from users",$conn); //Load all the data from Table echo "<table border=5><tr>"; while($field = mysql_fetch_field($result)){ //get each field name echo "<td> ".$field->name." </td>"; } echo"</tr>"; while($rows = mysql_fetch_row($result)){ echo"</tr>"; for($i = 0; $i < count($rows); $i++) echo "<td> ".$rows[$i]."</td>"; } echo "</tr></table>";
?>