This question might seem strange but I have been searching for an answer for a long time and I couldn't find any.
Let's suppose you have a blog and this blog has many post entries just like any other blog. Now each post can have simple user comments. No like buttons or any other resource that would require data management. Now the query is: Can I store user comments on a single text file? Each post will be associated to a text file that holds the comments. So, if I have n posts I'll have n text files.
I know I can perfectly do this, but I have never seen it anywhere else and no one is talking about it. For me this seems better than storing all coments from all posts in a single mysql table but I don't know what makes it so bad that no one has implemented it yet.
Storing comments in text files associated with corresponding post? Lest see if it's good idea.
Okay adding new comments easy - write new text to the file. But what about format of your data? CSV? Ok then you would have to parse it before rendering.
Paging. If you have a lot of comments you may consider creating paging navigation for it. It can be done easily, sure. But you would need to open the file and read all the records to extract say 20.
Approve your comments. Someone posted new comment. You place it with pending status. So.. In admin panel you need to find those marked comments and process then accordingly - save or remove. Do you think it's convinient with text files? The same if use decided to remove its comment himself.
Reading files if you have many comments and many posts will be slower the it would be in case of database.
Scalability. One day you deside to extend you comments functionality to let one comment to respond to another. How would you do it with text files? Or example from comments by nico: "In 6 months time, when you will want to add a rating field to the comments... you'll have a big headache. Or, just run a simple ALTER query".
This is just for beggining. Someone may add something.
Well, there are good reasons why this isn't done. I can't possibly name them all, but the first things that come to mind:
Efficiency
Flexibility
Databases are much more efficient and flexible than plain text files. You can index, search and assign keys to individual comments and edit and delete any comments based on their key.
Furthermore, you'd get a huge pile of text files if the blog is quite big. While in itself that's not a problem, if you all save them in one directory, it can grow out of proportion and really increase the access time needed to find and open a specific text file.
Related
I would like to make full use out of MySQL for the purpose of a (web) application I have developed for a chiropractor.
So far I have been storing in a single row for [every year] for what are called progress notes. The table structure looks something like this (progress_note_id, patient_id, date (Y-0-0), progress_note). When the client wishes to append for the year of the current progress notes, he simply clicks at the top of a textarea (html), which I use TinyMCE JavaScript library, to make a new entry date along with the shorthand notes to go at the beginning of the column (progress_note). So far its been working ok, if there are 900+ clients (est.) there could potentially be 1300+ progress notes, for each year since the beginning of the application (2018).
Now the client wishes to be able to see previous progress notes (history), but is unable to modify any previous notes, while still be able to write new ones. The solution I have come up with is to use XML inside the textarea, and use PHP to decipher the new notes from the old ones.
My problem however is if I should have to convert my entire table from a yearly to a daily, that it could take up a lot of time and energy to convert multiple notes into each single rows, (est. 10x) Which could end up being 13,000+ rows. I realize that no matter what method I choose to do is going to be a lot of work. Another way around this perhaps I found was to use XML column type in MySQL to potentially store multiple records, and if I wish to append it, all I would need is PHP to interpret the entire XML and add a new child node, to the beginning. Each progress note is 255 - 500 chars. And in worst case scenario, if the patient was to be 52 times a year (1 for every week), there shouldn't be a large enough overhead.
Is this the correct way to solving this problem? I do wish to keep with MySQL DB and I realize that MySQL is not an intended for XML. And for some clarification, what I hope to accomplish is the same thing I intended to do with current progress notes, but with XML. I believe in ascending order (newer -> oldest).
<xml_result>
<progress_note>
<date>2020-08-16</date>
<content></content>
</progress_note>
<xml_result>
Thank-you for any of your time and for any suggestions.
Firstly, 13000+ is not a problem for mysql. In most case for web application, mysql can handle more than 10m+ records for a single instance with a good performance.
Secondly, you can use either XML or JSON format in a text field and handle the decoding in your application.
I am very frustrated with my one old month problem. This is my first web page and it's quite complicated (for me).
My problem is with AND and OR in filtering categories in google maps. All tutorials go in the direction of the OR (golf OR theather). What about Golf and London? The more boxes checked, the less markers on the map.
I have two questions:
(1)
I am trying to follow this tutorial. I guess this is a trivial question: where is the data that is displayed in the panel? (I have followed several other tutorials and never had problems with finding the data, but this one...). I believe this tutorial may solve my second question below.
(2) The goal is to have a real estate page where user-sellers can insert properties for sale and user-buyers can view it, filtering the the data by multiple checkbox and/or drop down menus.
The problem I have is that I can't find a way to coordinate the OR and AND.
OR: I could use the Mike's tutorial and I have studied it very carefully.
I didn't find any tutorial when the filters get more complex.
(2B) I tried to work with my old post, and it works with OR as well. but couldn't find the right code when user only checks one (or two) box (like anything in Berkeley). The code(based on the kind Jobsen's code) required user to fill out all checkboxes all the way to the end, then the marker would show up. Couldn't check only 2 boxes and leave others unchecked. Sometimes I want the first filter (City) to be filtered a second time (Bedrooms). Not add any Berkeley + Bedrooms (2 or 3 or 4). Or only Berkeley. Or Berkeley +zip code + type + bedroom OR any combination. The and / or were not working as expected.
Any help with any of the above will be greatly appreciated. Feel free to add any info in the old post as well.Thank you again for your time.
Answer for the question (1) above, pick one:
(a) CSV file; then take a look at this.
(b) stackoverflow question and answer;
(C) you tube;
i chose CSV format. Here is a screenshot to turn csv format into a table using phpmyadmin.
To do the static tutorial which requires only CSV file and not Json (no need to mess with phpmyadmin): download the csv document, but don't open and save it as csv from MS Excel. Saved it inside the notepad as csv file. No idea about google docs.
Any help with the other part of my question (how to filter database with Jquery or Javascript) will be greatly appreciated.
my client is asking for an auto-rotating news feed type thing on their site. The content will not change, but it will automatically move from item to the next. It will also allow the user to mouse over previous items and hold them in place.
This is best shown by the type of thing you find on Yahoo's homepage:
The four news items will auto-rotate, but when a user puts their mouse over one (as shown), it will stop rotating and just show that one, until they move it away (then it will continue auto-rotating).
I imagine I can do this with a lot of $('item1').fade and $('item2').appear type malarky using Prototype and Scriptaculous, but I was wondering if there was a better way, or an existing bit of code I could use (it seems like quite a common thing, these days).
Thanks for any tips or assistance!
Took a little googling to find one but this looks exactly like your provided example:
http://www.agilecarousel.com/flavor_2.htm
Here are some other, simpler carousels that have been out in the wild for a little longer:
http://sorgalla.com/projects/jcarousel/
http://www.thomaslanciaux.pro/jquery/jquery_carousel.htm
http://www.baijs.nl/tinycarousel/
Hope this helps and good luck!
I apologize if I'm missing any details to this question, I really don't know what I need.
I've got a table of the "Top X" of the week that I need to update daily. I want it to be as easy 'in and out' as possible to update.
Ideally I'd like the information taken from a file I can edit and upload to my server and auto-update the table, or something like this.
My list of Top 10 'xyz' is currently static. This means every time the order changes (which could be 20 times a day) I have to manually update the table. Is there a way I can dynamically update my table in accordance to the "official list" on another website?
Is this possible? I'm going to guess they will require PHP, but really haven't gone into too much of it. Any links to help me accomplish this are very much appreciated!
There are many ways to do this. Here are a few.
Just Edit the HTML
Read from a database.
Dynamically load txt file (eg JSON,CSS) via JavaScript.
Dynamically load html file (with just the table) via JavaScript.
I am facing a problem on developing my web app, here is the description:
This webapp (still in alpha) is based on user generated content (usually short articles although their length can become quite large, about one quarter of screen), every user submits at least 10 of these articles, so the number should grow pretty fast. By nature, about 10% of the articles will be duplicated, so I need an algorithm to fetch them.
I have come up with the following steps:
On submission fetch a length of text and store it in a separated table (article_id,length), the problem is the articles are encoded using PHP special_entities() function, and users post content with slight modifications (some one will miss the comma, accent or even skip some words)
Then retrieve all the entries from database with length range = new_post_length +/- 5% (should I use another threshold, keeping in mind that human factor on articles submission?)
Fetch the first 3 keywords and compare them against the articles fetched in the step 2
Having a final array with the most probable matches compare the new entry using PHP's levenstein() function
This process must be executed on article submission, not using cron. However I suspect it will create heavy loads on the server.
Could you provide any idea please?
Thank you!
Mike
Text similarity/plagiat/duplicate is a big topic. There are so many algos and solutions.
Lenvenstein will not work in your case. You can only use it on small texts (due to its "complexity" it would kill your CPU).
Some projects use the "adaptive local alignment of keywords" (you will find info on that on google.)
Also, you can check this (Check the 3 links in the answer, very instructive):
Cosine similarity vs Hamming distance
Hope this will help.
I'd like to point out that git, the version control system, has excellent algorithms for detecting duplicate or near-duplicate content. When you make a commit, it will show you the files modified (regardless of rename), and what percentage changed.
It's open source, and largely written in small, focused C programs. Perhaps there is something you could use.
You could design your app to reduce the load by not having to check text strings and keywords against all other posts in the same category. What if you had the users submit the third party content they are referencing as urls? See Tumblr implementation-- basically there is a free-form text field so each user can comment and create their own narrative portion of the post content, but then there are formatted fields also depending on the type of reference the user is adding (video, image, link, quote, etc.) An improvement on Tumblr would be letting the user add as many/few types of formatted content as they want in any given post.
Then you are only checking against known types like a url or embed video code. Combine that with rexem's suggestion to force users to classify by category or genre of some kind, and you'll have a much smaller scope to search for duplicates.
Also if you can give each user some way of posting to their own "stream" then it doesn't matter if many people duplicate the same content. Give people some way to vote up from the individual streams to a main "front page" level stream so the community can regulate when they see duplicate items. Instead of a vote up/down like Digg or Reddit, you could add a way for people to merge/append posts to related posts (letting them sort and manage the content as an activity on your app rather than making it an issue of behind the scenes processing).