Page 1 of 1

How to Drop Table on Session Condition

Posted: Mon Apr 17, 2006 8:23 am
by banko
Hi Everyone,

I have created a php/mysql site. When a guest comes to the site a temp table is automatically created for them in mysql, saving all their entries and data. I would like to have this temp table dropped when the guest leaves the site. Can someone please tell me how to accomplish this?



Thanks for your help guys,

Banko

Posted: Mon Apr 17, 2006 8:27 am
by feyd
Why not keep all this data about their entries in a single table?

I'd suggest using database sessions or a similar facility.

Posted: Mon Apr 17, 2006 8:30 am
by banko
all the data for that user is stored in a single table, i want to know how to drop that table when they leave.

Posted: Mon Apr 17, 2006 8:34 am
by feyd
And I'm suggesting that you store that information, across all sessions, in a single table. No more temporary tables.

Posted: Mon Apr 17, 2006 8:43 am
by Chris Corbyn
This sounds like a bad design. I wouldn't be creating new tables on a per-user basis. Rather I would make use a the idea of relational databases and have tables for the relevant components. So you'd have for example a users tables, and a user_preferences table.

Posted: Mon Apr 17, 2006 9:02 am
by banko
the table is for a temporary quote.

Basically the person fills out a form, the data is retrieved from the form, a query is sent to the database to get the rates on the selected item. Calculations are made to the data submitted and then all is saved to the guests table so he can keep adding items. Every time he makes an addition the page displays what he has added so far and what the total is, and gives the option to add or remove data from his table.

Basically unless you know away to store and keep a running track of his entries without creating a table for him I would love to here it.

I am new to database design, and welcome any suggestions. Think of the table as a shopping cart that i want deleted at the end of his session.

Posted: Mon Apr 17, 2006 9:15 am
by feyd
two options:
Two tables or one table

The two table approach
Store minor (more global) details about the possible order here (this is where the session data is sent, overall)

The second table holds items in their order. Each item is keyed to the Session ID or some other reference to their entry in the first table.


The one table approach
Only items are kept in this table. They reference to the user in some unique way. Some of the data stored here will likely be redundant.