0% found this document useful (0 votes)
936 views

Mini Project: Management of A Discussion Forum

The document describes creating a database to store a discussion forum. The database will contain tables to store user profiles, discussion rooms with themes, and messages within each room that can be responses to other messages. Procedures are defined to add users, rooms, initial messages, and responses to the database and display the discussion threads and messages.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
936 views

Mini Project: Management of A Discussion Forum

The document describes creating a database to store a discussion forum. The database will contain tables to store user profiles, discussion rooms with themes, and messages within each room that can be responses to other messages. Procedures are defined to add users, rooms, initial messages, and responses to the database and display the discussion threads and messages.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Mini project: Management of a discussion forum

We want to create a database to store a discussion forum on the internet.

Forum users must be registered, the database will therefore contain a

user profile (name, email, date of registration, number of participation in the forum).

The forum will be divided into different discussion rooms, each room will have

a theme and one of its users will play the role of moderator.

A moderator will be automatically appointed in a room when he is the user who

posted the most messages in this room.

In each chat room, users can create new topics or reply to existing messages.

A message will have an author, a date of writing and text.

The discussions will have a tree structure:

a message can have a single parent and multiple children.

A subject can be opened or closed (in this case we can no longer post)

Create the following tables:

CREATE TABLE utilisateur(id_utilisateur INTEGER PRIMARY KEY,

nom VARCHAR2(32),mail VARCHAR2(64) UNIQUE,

inscription DATE,

nb_action INTEGER);

CREATE TABLE salle(id_salle INTEGER PRIMARY KEY ,

theme VARCHAR2(128),

id_moderateur INTEGER REFERENCES utilisateur(id_utilisateur),

nb_thread INTEGER);

CREATE TABLE message(id_message INTEGER PRIMARY KEY,

id_parent INTEGER NULL REFERENCES message(id_message),

id_auteur INTEGER REFERENCES utilisateur(id_utilisateur),

date_envoi TIMESTAMP,
id_salle INTEGER REFERENCES salle(id_salle),

corps VARCHAR2(512),

etat VARCHAR2(6) CHECK ( etat IN ('OUVERT','CLOT')));

Take the time to understand the schema of the database and the constraints of integrity.

To display, use the procedure DBMS_OUTPUT.PUT_LINE (…).

Questions

1. Explain the schema of the database

2. Sequences The keys of the tables are integers,

to obtain different integers we use under Oracle sequences:

CREATE SEQUENCE seq_utilisateur

START WITH 1

INCREMENT BY 1

NOMAXVALUE;

Create in the same way sequences to generate the room key and the message key

3. Adding users Create a PL / SQL procedure to add a forum user to the database

CREATE OR REPLACE PROCEDURE nouvel_utilisateur(pnom IN VARCHAR2,pmail IN VARCHAR2)

AS

/* déclaration*/

BEGIN

/* instuctions*/

END ;

SHOW errors /*pour voir les erreurs de compilation*


This procedure wraps the insertion in the table, it takes care of obtaining

the new number in the sequence and today's date.

To obtain this date you can use SELECT CURRENT_DATE FROM DUAL

4. Test Create a few users by calling the function:

CALL new_user ('bob', '[email protected]');

5. Adding a room Create a procedure to add a room to the forum. Create a few rooms.

CREATE OR REPLACE PROCEDURE nouvelle_salle (ptheme IN VARCHAR2)

6. Adding a message Create a procedure to post a message that will be the start of

a new discussion thread. Create a second procedure that creates a response to a

previous message.

CREATE OR REPLACE PROCEDURE new_message (pid_salle IN INTEGER, author

IN INTEGER, msg IN VARCHAR2)

CREATE OR REPLACE PROCEDURE nouvelle_reponse (father IN INTEGER, author IN INTEGER, msg IN


VARCHAR2)

After inserting the new message in the message table, the procedure will

possibly update (if necessary) id_moderateur in the room where the message was posted.

Post some messages and check the correct update of the moderator

7. Closure of subject

Create a procedure to close a subject (1 message).

The procedure will generate an error if the user is not a moderator in the room where

the subject he wishes to close is located.

CREATE OR REPLACE PROCEDURE subject_close (pid_message IN INTEGER, pid_user IN INTEGER)


8. Prevent replies to a closed topic

Create an exception to alert users when they post replies in a closed topic.

9. Tree view

Write a request or a procedure allowing to display the messages and the answers in

arborescent form (in-depth course prefix of the forest of trees representing the threads of
discussion).

Display example:

[email protected]: A message from bob! [OPEN]

[email protected]: A bill message! [OPEN]

----> [email protected]: A bob response! [OPEN]

---------> [email protected]: A response from bill! [CLOT]

-----> [email protected]: A response from Jim! [OPEN]

[email protected]: A message from Jim [OPEN]

You might also like