views:

42

answers:

1

I'm trying to make a webapp. The application I am making for myself to help with foreign language translations for classes at my college, and I am hoping to make it available online. All the data that the site saves is in a format like:

section 1
     foreign text
     translated text
section 2
     foreign text
     translated text

The app relies on javascript and jquery, so I thought JSON would be a good format for the data. I've got a basic user system set up, I just need to know the best way to handle the projects. What seems easiest is to just have a directory on my site in which there is a folder for every user. Every user's folder would have an individual file for each project they've made. In the load dialog the php will print the list of files in the user's directory so as to make a list of saved projects.
I don't believe this is the best solution; I'm kind of hacking this together as I go along. Would one giant json file for each user be better, or just a pain to code?

+3  A: 

I would put everything in a database and not in individual files.

Is there a reason you can´t use a database?

Example:

The simple basic setup with a database would be something with 2 tables:

Users:

  • user_id
  • name
  • etc.

Texts:

  • project_id
  • user_id
  • foreign_text
  • translated_text

Where the foreign_text and translated_text are of type text.

jeroen
I wasn't aware you could input large amounts of data into a database. I'm using mysql, any info on how to do this?
DavidR
Using a database will make whatever you're trying to do extremely simple. Each "section" (foreign - translated) could be a row in a `sections` table, along with the project ID to which it belongs. Similarly a `projects` table would hold the user ID to whom it belongs. And finally a `users` table with user details. Now you simply need to select all projects for a given user, and then all sections in a project file when the user opens a file.
casablanca