Sei sulla pagina 1di 6

Database Management System - Project

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.

1.2 Develop environment


Working alone using MySQL for the database engine and PhP for the web part.

1.3 Design process


1) Conceptual design, including the structure of the whole system: how many tables there are, what is the specific content of each table, etc. Draw the whole E-R diagram. (Basically done, need to be modified) 2) Writing SQL codes to satisfy the conceptual design.(Working on...) 3) Writing PHP codes to create the interface websites.(To be done)

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

Table name Index primary key

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

Storing comments on user profiles and pictures

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

2.3 E-R diagram


contacts picture_id user_id real_name pame

user_name

age user_id

Users
location

Add_pic

Picture
description

group Com_user profile Create comment_id Com_pic

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` ;

2) Create table "Users" in the database "DBMS_project":


CREATE TABLE `dbms_project`.`Users` ( `user_id` INT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `user_name` VARCHAR( 30 ) NOT NULL , `real_name` VARCHAR( 50 ) NULL , `age` INT( 8 ) NULL , `location` TEXT NULL , `profile` TEXT NULL , `group` VARCHAR( 30 ) NULL , `contacts` TEXT NULL , UNIQUE ( `username` ) ) ENGINE = InnoDB

3) Create table "Picture" in the database "DBMS_project":


CREATE TABLE `dbms_project`.`Picture` ( `picture_id` INT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'To identify pictures, auto_increment', `pname` VARCHAR( 30 ) NOT NULL COMMENT 'Picture name', `user_id` INT( 20 ) NOT NULL COMMENT 'Uploaded by which user', `description` TEXT NULL COMMENT 'Picture description' ) ENGINE = InnoDB

4) Create table "Comment" in the database "DBMS_project":


CREATE TABLE `dbms_project`.`Comment` ( `comment_id` INT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'To identify comments, auto_increment', `type` VARCHAR( 10 ) NOT NULL COMMENT 'Identify comments on user / pictures', `comm_user_id` INT( 20 ) NOT NULL COMMENT 'Uploaded by which user', `user_id` INT( 20 ) NULL COMMENT 'Comment on which user', `picture_id` INT( 20 ) NULL COMMENT 'Comment on which picture', `content` TEXT NULL COMMENT 'Comment content' ) ENGINE = InnoDB

5) Create table "Group" in the database "DBMS_project":


CREATE TABLE `dbms_project`.`Group` ( `group_id` INT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'To identify groups, auto_increment', `group_name` VARCHAR( 30 ) NOT NULL COMMENT 'Group name', `creator_id` INT( 20 ) NOT NULL COMMENT 'Created by which user' ) ENGINE = InnoDB

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>";

//loading each row

?>

4.2 Screen shots


4.2.1 Database

4.2.2 Table users

4.2.3 Data in Table users

4.2.4 Data displayed in the Website

Potrebbero piacerti anche