Re: How to store a chat in a mysql db
From: J.O. Aho <user_at_example.net>
Date: Wed, 20 Mar 2019 23:01:22 +0100
Message-ID: <gffrhiFb169U1_at_mid.individual.net>
>
> Ok, it's what I understood!
>
>
> Yes of course but sometimes when you find examples of the code on
> internet it's now always so clear!
>
> Now I should add a chatlog's table to store every chat of every users
Date: Wed, 20 Mar 2019 23:01:22 +0100
Message-ID: <gffrhiFb169U1_at_mid.individual.net>
On 3/20/19 12:37 PM, ^Bart wrote:
> Thank you for your reply! :)
>
>> The handler is the name of the user, the user_id is really just the id >> column of the chat_user table.
>
> Ok, it's what I understood!
>
>> I think a better design had to be using a better name for the id >> columns in each table, like use user_id even in the chat_user table, >> chat_id for the chat table and so on, this makes it less likely that >> you make bad joins or confuse things.
>
> Yes of course but sometimes when you find examples of the code on
> internet it's now always so clear!
>
> Now I should add a chatlog's table to store every chat of every users
You have it already, the chat_line table
> also is the user will delete himself, I don't understand if it's better
> to do a sql script to copy chat to the chatlog's table or if it could be
> more "nice" to create a table with FK...
Simplest is to just mark the user as deleted in the chat_user by adding a new column for example `deleted` this could either be a bit or datetime, depending on if you want to know when the user deleted himself from the chat.
-- //AhoReceived on Wed Mar 20 2019 - 23:01:22 CET