Database Projects
Database Projects
Kunal Chawla (2001182) Student V Semester B.Tech. IIIT-A Indian Institute of Information Technology Allahabad, & ROHIT Dhawan (2001195) Student V Semester B.Tech., Indian Institute of Information Technology Allahabad
Dr. Sudip Sanyal (Project Mentor), Asst. Professor, Indian Institute of Information Technology Allahabad
Preface
This Project deals with Instant Messenger Applications three modules: Server, Database and the Client. The Design of the each module of the project is highly innovative and is made in accordance to the need of the users. An Instant Messenger makes the communication simple as users can exchange messages instantly. In Addition the facility to exchange drawings can help to express what cant be achieved by just plain text. There should be mechanisms to add, delete and update friends, their information and friend list. An ideal server should provide reliable and secure communication. An ideal database must maintain data correctness and integrity. And an ideal client must utilize the functionality to the maximum that server provides.
Certificate
This is to certify that Mr. Kunal Chawla and Mr. Rohit Dhawan , fifth semester of the Indian Institute of Information Technology, Allahabad, have rightly made a project on server , database and client for Instant Messenger Application . During the course of development, they have shown commendable performance and diligent effort that had led to the appreciable progress of the project till date. Their contribution to the project is praiseworthy. Certified by
Dr. Sudip Sanyal Project Mentor, Indian Institute of Information Technology Allahabad
Acknowledgement
First and foremost we would like thank our project guide Dr SudipSanyal for his learned guidance. The project is in its present form because of his inspiring and caring guidance. Also I would like to thank all my batch mates who came up with valuable suggestions and were ready with their positive comment all the time, whether it was an offhand comment to encourage us or a constructive piece of criticism
Table of Contents
INTRODUCTION .............................................................................................................................. 6 GOALS .................................................................................................................................................. 8 SYSTEM REQUIREMENTS ............................................................................................................ 9 DESIGN.............................................................................................................................................. 10 BASIC DESIGN ............................................................................................................................. 10 SERVER .......................................................................................................................................... 10 FORWARDING PROGRAM .......................................................................................................... 12 CLIENT ............................................................................................................................................ 13 DATABASE ..................................................................................................................................... 15 DESIGN OF PROTOCOL STRING .............................................................................................. 17 SPECIAL FEATURES ..................................................................................................................... 20 GUI ...................................................................................................................................................... 21 CONCLUSION .................................................................................................................................. 25 BIBLOGRAPHY ............................................................................................................................... 26
Introduction
Our application consists of these basic modules y Server y Database y Forwarding Program y Client In order to use the application the user first needs to create an account with the server. This includes form filling and sending that to the database. After the creation of the account user need to sign in. In the sign in procedure user is authenticated and a session key is generated which is required in further interactions with the server and the forwarding program. The user can add/delete/update friends information and maintain the friend list. The database contains the information regarding the online status of the user, the friend list of the user, offline messages etc. The Client interacts with the server using JAVA RMI. And each client communicates with each other using a Forwarding Program .The forwarding Program is a program which allows the clients to communicate with each other using TCP socket. The client sends the message addressing the user to the forwarding program which is running on a machine with a known IP address. The forwarding program after receiving the message from a user forwards the message to addressee. If it is unable to send the message to the required host then it returns an error message to the Client containing the same message.
Client then tries to send the message using the Server, the server then tries to send the message and if it is unable to do so then it saves the message as an offline message. The offline messages addressed to a particular client are then retrieved by the Client when he logs in. The Server basically provides a call to retrieve the offline messages and various other things. So retrieving information from the server highly depends on the design of client. So YAM server is an independent module which provides functionality to the clients. Now the client design should be such that it effectively and efficiently utilizes the functionality provided by the server. YAM client is one such possible client design.
GOALS
y To design and implement an ideal database for storing the user information. y To design and implement a server which will maintain the database and should be able to provide functionalities including queries to the database. y To design and implement a forwarding program that will forward messages from one client to other. y To design and implement a client which will be able to communicate text messages as well as messages in the form of geometrical figures by using the functionalities provided by server and the forwarding program. y To design and implement a suitable GUI for the Client.
SYSTEM REQUIREMENTS
Hardware Interfaces A standard PC with 64MB RAM, 166MHz Celeron (or higher) processor, a keyboard, a mouse, a monitor for a client. Software Interfaces The following software requirements are found to be necessary:
y y Java SDK Version: 1.4.2 or later Oracle 8i for database
Communications Interfaces Internet, Intranet with suitable hardware requirements like modem, Ethernet card.
* The hard disk size of the database and hardware requirements for a server and forwarding program depends on the number of users.
Design
BASIC DESIGN
The Client contacts the forwarding program using TCP/IP sockets. The Client contacts the server using JAVA RMI. And the interaction between the database and the server, forwarding program occurs through JDBC.
SERVER
10
The client talk server receives requests from the server and passes them an object of the client and server talk implementation which provide the various functionalities to the client. Some of the functionalities are listed below. The client and server talk implementation in turns uses functionalities of server data talk which provide an interface between database and client and server talk implementation.
SOME OF THE IMPORTANT FUNCTIONS IMPLEMENTED AT THE SERVER ARE Authenticate Authenticates the user using the userid and the password. A session key is generated whenever a new session is started by the client, this key is then used in verification when ever client calls the server. Disconnect This function is used to end a particular session. The entry of the user is removed from the list of online users. getFwdInfo This function sends the information regarding the forwarding server like ipaddress. IsFriendOnline Finds whether a friend is online or not. Check This function is called each time the Client wants to communicate with the server. It checks the IP of the client with the particular key for the session. So this is used to verify the client whenever client calls server after authentication. GetFriendList Returns the friend list for the userid with the information like online status of friend and the information like nickname, firstname and the last name. GetFriendInfo Returns friendElement object(containing information about the friend) by searching in friendlist of the userid. Return equals to null means that the friend was not found in friend list. AddFriend 11
Adds a tuple to the friend list corresponding to a new friend .Returns true if friend is added else false. DeleteFriend Returns true if friend is deleted from friend list else false. UpdateFriend Updates the friend information like nickname,firstname,lastname etc for a particular userid in the friend list UserExists Executes a query to the server to check if a user exists or not and returns true if userid is found else false. Ping After some time the client pings the server(that means it call a ping procedure) which updates the time to live for that online client. If client doesnt call the ping with the particular time then the client is disconnected and the session is destroyed. Broadcasttoonlinefriends: Used to broadcast a particular message to online friends. This communication is not reliable as message is not saved if untransfered. SendMessageViaServer: Used to send a message to a user. This communication is reliable as message is saved as an offline message if untransfered.
FORWARDING PROGRAM
12
The clients and forwarding program interact using TCP/IP Sockets. The requests from the clients enter a queue maintained by the forwarding program. The forwarding program takes each element from the queue and verifies the userid and corresponding session key against those values retrieved from the database. If these values match then a unicast thread is created which forwards the message to addressed userid by finding out his ipaddress from the database. If these values are not matched then a message is passed back to sender about the invalid session key. And if the addressed userid is offline (i.e. program was unable to fetch the ipaddress of addressee from the database) or if the ipaddress is unavailable on the network then the message is forwarded back to the sender using a unicast thread. The unicast thread use TCP/IP Sockets for communication. The Forward program data talk provides an interface between the database and the forwarding program. The forward program data talk has read only grants for the database that adds to the security.
CLIENT
13
On the client side messages are received using TCP/IP Socket interface and are added to the receiver queue. Messages are taken from the queue one by one and are then decoded by the receiver protocol. The tasks are then assigned to Worker Threads which carry out the work desired by the corresponding protocol string(the encoded message). A task can be to perform the job of displaying them through the GUI. Similarly on the sending side Work Flow Threads take messages from the user through the GUI. These messages are then encoded by the sender protocol in a particular format which considers the addressee , the function required etc. Then they enter the Sending Queue after which they are sent to the Forwarding Program using TCP/IP Socket interface. The client retrieves the reference to the server object using JAVA RMI. The various functionalities provided by the server are called using this reference.
14
DATABASE
The Data base consists of the following tables as under mentioned. The data correctness is maintained by the application of checks and referential integrity constraints(foreign key constraints).
15
MAIN contains information regarding the user USERID userid of the user ( Primary Key ) , 15 characters FNAME First Name of user , 20 characters LNAME Last Name of user, 20 characters PASSWORD password of the user , 15 characters ,not null AGE age of the user (check on age > 0) , number GENDER gender of user (check on gender = M or F ),1 character LOCATION location of user , 25 characters OCCUPATION occupation of user, 25 characters FLIST contains information regarding the friend list of users USERID userid of the user (references MAIN(userid)),15 characters FRIENDID userid of the friend(references MAIN(userid)),15 characters FNAME First Name of user , 20 characters LNAME Last Name of user , 20 characters NNAME Nick Name of user , 20 characters ONLINE_USERS contains information regarding the online users like userid ,session key, ipaddress. KEY session key of the user, not null , 6 characters USERID userid of the user (references MAIN(userid)),15 characters IPADDRESS ipaddress of the user , 15 characters TIMETOLIVE expire time of this tuple, number OFFLINE_MES contains the information regarding the offline messages USERID userid of the user (references MAIN(userid)),15 characters MESSAGE message , 550 characters
16
FWD_INFO contains information regarding the forwarding program IPADDRESS ipaddress of the machine, 15 characters FWDNAME name of the machine , 15 characters PORT port on which the requests are received , number TIMEOUT timeout for read operation for a socket, number
17
X=2 : ITS AN INVITATION MESSAGE X=3 : ITS A PERMISSION MESSAGE X=6: Reply from router, saying u need to login again only 6 is sent. Reply from router, saying message undeliverable This means after X , rest is DESTINATIONID(padded) + Message. So whenever reply for X=7 come, send an offline to userid. FOR X=7 THE SUBSTRINGS ARE DIFFERENT AFTER X (15 CHARACTERS (PADDED))DESTINATIONUSERID REST MESSAGE SO WHENEVER A REPLY OF THIS SORT: NEXT ACTION AN OFFLINE TO DESTINATIONID X = 9: Sender is online X = 8: Sender is offline SEND .
X=7:
SUBTYPE1=Y X=1: Y = MEANS THE SIMPLE MESSAGE X=2: Y = 0 IT MEANS THE INVITATION Y =1 IT MEANS THE REPLY TO INVITATION X=3: Y=0 IT MEANS ASK Y=1 IT MEANS REPLY
SUB-TYPE2=Z X=1: Y=1: Z= MEANS THE SIMPLE MESSAGE X=2: Y=0: Z= MEANS THE INVITATION X=2: Y=1: Z=0 MEANS THE REPLY OF INVITATION AND REPLY IS : ACCEPETED 18
X=2: Y=1: Z=1 MEANS THE REPLY OF INVITATION AND REPLY IS : DENIED X=3: Y=0: Z= MEANS THE PERMISSION (ASK) X=3: Y=1: Z=0 MEANS THE REPLY OF PERMISSION AND REPLY IS : ACCEPETED X=3: Y=1: Z=1 MEANS THE REPLY OF PERMISSION AND REPLY IS: DENIED SUB-TYPE3=P P CAN BE COMBINED WITH X,Y,Z TO GIVE DIFFERENT LOGICAL STATEMENT SO IF P IS UNUSED THEN P= So we conclude as: X=1: Y=1: Z= : P= MEANS THE SIMPLE MESSAGE X=2: Y=0: Z= : P= MEANS THE INVITATION X=2: Y=1: Z= 0 : P= MEANS THE REPLY OF INVITATION AND REPLY IS : ACCEPETED : X=2: Y=1: Z= 1 : P= MEANS THE REPLY OF INVITATION AND REPLY IS : DENIED X=3: Y=0: Z= :P= MEANS THE PERMISSION (ASK) X=3: Y=1: Z= 0 :P= MEANS THE REPLY OF PERMISSION AND REPLY IS : ACCEPETED X=3: Y=1: Z= 1 :P= MEANS THE REPLY OF PERMISSION AND REPLY IS : DENIED
19
Special Features
Reliability The forwarding program after receiving the message from a user forwards the message to addressee. If it is unable to send the message to the required host then it returns an error message to the Client containing the same message. Client then tries to send the message using the Server, the server then tries to send the message and if it is unable to do so then it saves the message as an offline message. If the same user logs in at different machine, his previous session is destroyed. Security No client is allowed to access the ipaddress of any peer. Only the forwarding programs ipaddress and servers ipaddress are revealed. Incase of forwarding program , we are using a database user with read only grants. But in case of server we have a database user with access restricted to desired amount. This definitely adds security features to database. Validation of User With every message being sent and with every remote method invocation , session key is checked before any activity. Correctness of information about online friends The client is supposed to call ping after some particular time. Even there is no call the client session is destroyed and is disconnected. To start the session again client has relogin. Drawing Board The drawing board provides the facility to express and convey those things which cant be conveyed by just plain text messages.
20
GUI
21
22
23
24
CONCLUSION
The entire project was a great learning experience in terms of improving our technical and interpersonal skills. All the modules have a common GUI standard and communication pattern which was decided after a lot of brainstorming sessions, keeping in mind our nave users. We have done a lot of documentation while we were building up the design so that if some other person(s) want to extend the project then they dont find any difficulty. It was a perfect application for our Software Engineering course and helped us look at projects in a different way . Before starting the coding, the specifications were decided for every group by suggestions from every possible source. Most of the modules we had planned to design were completed but still there is a scope for improvements in terms of some extra functionalities and better GUI .We look forward to work on this project in future also and make our module as user friendly as possible .
25
BIBLOGRAPHY
Core Java 2 (Volume 1 ) Core Java 2 (Volume 2 Advanced Features) JDK 1.4 - Documentation
26