Storing text message in a temp space - mysql

Hi I am trying to design a discussion forum where i want to archive the text messages and store it in a folder(or any place using path). Whenever the user again logs in and want to continue i want to extract it and display the previous chat. So question is am i doing correct design in archiving text and retrieving it again ? If yes what is the best format to archive the text (.pdf or .csv or .txt) and store it in a place suggested by path (path info is stored in mysql) or in a folder and folder path in mysql.
The discussion forum looks like twitter. Please throw some light on the design part.
Thanks in advance.

Wouldn't be better to work directly in the database?
That way you can store all information in a organized and indexed way.
All you need is create your tables and columns attempting to the data size. Like VARCHAR(NUM OF BYTES) or TEXT() for a long text.
For any additional content, like attachment or answers, you can use other tables referencing the original table throught Primary Key column.

Related

Mapping users to all of their files(URLs) in a mysql database.

What I want is that when I have looked up a user in a table, I want to list all the file urls that the user have access to. My first thought was to have a field in the table with a list of file URLs. However, I have now understood that there are no such field type.
I was then thinking that maybe ForeignKeys might work, but I am having trouble getting my head around it.
Another solution maybe is to have one table for each user, with each row representing each file.
What would you say is best practice in this case?
I am also going to expand into having shared files, but thought that I'd address this issue first.
Suggest you explore the JSON Data Type
2 tables: user and user_uri_permission? 2 columns in the second: userID and URI. When the User-URI pair is in the table the use has access.

Is there any way to read two different names from same column?

I have table and in the images column I am saving the names of the images needed for that row data, I want to know if there is any way to read multiple image name which are in the same column(and row) and fetch corresponding image from the folder.
I can read one image name and fetch that image from the folder, but not more than one.
Do I have to create multiple column to achieve this?
Even of you could, its not a good design to store multiple image names on the same column(not just for images, but any type of data in general), research about "normal forms"(or normalization) in database design, the best approach would be to store them on another table with a 1 to many relationship(the images table would have a foreign key to the original row),this way you can easily fetch image by image with a simple join ,and use the current code "for one image" you already have
Microsoft SQL 2016 have JSON storage support. You could store the names in JSON in a single column and return the result as JSON. Something like:
SELECT a.ImageNames FROM table1 a FOR JSON
Then you could load the JSON into an object with a list property.
Some variation of that. It's difficult to tell because we don't know what language or framework you're using other than MS SQL. But if you want to store multiple values in a single column/row, JSON would be a good way to do it.
You could also just use a simple CSV value.

save unlimited data to sql database

I would like to know how its possible to store 1000 or more images and be able to access them when you log in to your account.
I tried doing it with database and link them to your email so that every time you log in your profile will show up. I found it difficult to do. I didn't want to create tables for each image.
What other way is their to store unlimited data without having to create a table? Just link email to be able to access data.
I hope i do not misunderstand your question, but can you not store your 1000 images on your server and save the file direction in a table? Similar to an admin system you could use a php form to upload the images, storing each name into the database, then you can use php and mysqli to retrieve them all into a page or wherever you want them. maybe add keywords to them so you can find them easily with:
<?php
include 'connect.php';
SELECT * FROM table WHERE keywords LIKE $search_key;
?>
Then its just a case of echo.
Hope this helps
It's all about 1 to many , you have to be able create not two but three table, one for user one for unique save and one for haw many save as he wants under the unique save. it's all about planning ahead

In a mysql database is it possible to find a table that would contain a specific column name?

I’m using a heavy duty CMS and have created a new data field for a certain content type. the data field is named ‘sort order’ or possibly ‘sort_order’. I’m assuming the data field is added to a table and have no way of knowing which table it was added to. When viewing the database via phpmyadmin there are simply too many tables to go looking for it.
Is there any way possible to do a search to find which table would contain this column name? or maybe an alternate method would be some look for most recent updated table?

What is the best dynamic column solution for advertisement webpage?

I'm developing website in which will be categorized advertisements. In each category will be possible different fields of input (example: for car there will be motor size, for cat there will be a race). So I'm thinking how to build database to manage this (I will use MYSQL database). One way you can see in attached picture, I know that also is solution to create table for each values datatape, but I'm wondering that it will slow down a website. This solution which is in picture will generate empty fields in sp_advertisement_value table what isn't good also.
What is in your opinion the best solution? Maybe there is something else?
p.s. Here is a link to database market.
You can store it like name/value pairs (more or less same to what you is described in the image you attached).
A simple schema would be a table having two columns name and value. Instead of having a column for each data type like value_int, value_string etc. have one single column value who's data type can be varchar (or Text as seems fit to you). You can do all the data conversion in your application code as per your needs.
You can do some normalization here too for instance instead of saving name you can make a separate lookup table named parameters having id, name and other related information and have the parameter_id in the table where you are storing parameter values.