To be clear, I'm not looking for opinions but rather facts based on actual in-the-field usage of different file structure types.
In researching, before asking this questions, I've seen many posts about what the right folder structure is for a web application. For example, I'll see someone list where the following should go: css, js, html, images, php. But, I haven't seen anyone go into much deptch about what the static directory structure should look like.
I have a lot of images in form of static/images/mustang_2017_front.jpg using Ford vehicles for example. Is it best to keep them in this flat file format or use a hierarchical folder structure such as static/images/mustang/2017/front.jpg. All the images are the same type for each car (e.g front, side, rear, top). Also, though I'm asking about images, I think the naming conventions standards apply to static files in general.
Option 1- flat
static/images/mustang_2017_front.jpg
static/images/mustang_2017_side.jpg
static/images/mustang_2017_rear.jpg
static/images/fusion_2017_front.jpg
static/images/fusion_2017_side.jpg
static/images/fusion_2017_rear.jpg
Option 2- hierarchical
static/images/mustang/2017/front.jpg
static/images/mustang/2017/side.jpg
static/images/mustang/2017/rear.jpg
static/images/fusion/2017/front.jpg
static/images/fusion/2017/side.jpg
static/images/fusion/2017/rear.jpg
Here are some of the benefits I can think of for each approach, but they're from a human perspective. Is one of the options easier to work with in code? Does it matter much? I just don't want to be setting myself up for something that's not scalable in the future.
Option 1- flat Benefits
all files have all information in the name
Option 2- hierarchical Benefits
from a human perspective it's easier to manually navigate and find what you're looking for using a hierarchical folder system instead of having a large number of files all in the same folder
To be clear, I'm not looking for opinions but rather facts based on actual in-the-field usage of different file structure types.
It is very much A. a matter of opinion and B. it depends on the actual implementation.
How are the files going to be used and by who. If your visitors are going to be downloading images from your site, they might end up with 10x front.jpg in their download folder. So for me that is not great. Also whoever is processing the files (e.g. a designer) could have the same name open in e.g. Photoshop and this won't make it clear. So I would say that option 2 isn't great in most cases I can imagine.
Option 1 however can result in a massive single folder with thousands of files.
I like stuff being descriptive and clear, to suit most cases. There is an Option 3 also; static/images/mustang/2017/mustang_2017_front.jpg. In my opinion this has the best of both worlds. The file name itself is descriptive and your folders are organised. You could easily delete e.g. 2015 when it's not used anymore.
Also think about if it should be mustang/2017/ or 2017/mustang/ for your case
[Edit: I have awarded the bounty but not the question, as I feel there is still a chance for a better answer.]
I usually code my MySQL data entry interfaces in php.
But for quick projects where I would like to focus on the web side of things (pulling data from the database), I am looking for a form front-end to MySQL. Ideally, this would be an off-the-shelf Win or OSX program that I can hand over to a friend or client so she can input data into forms.
An Example
The lines above summarize the question, but here is a typical situation to showcase why "just give them phpMyAdmin" or some other web interface to MySQL generally wont work.
We have two main tables: images and albums. The third is an associative table that associates images with albums.
Images: id (PK), filename
Albums: id (PK), album
Album_Image: id (PK), imageid, albumid (these are foreign keys: the two id PKs from the Images and Albums tables)
For big projects, I don't mind coding a nice "back-end" interface (CRUD) that lets me edit data in a very comfortable, customized way.
For small projects, for instance an image gallery for a friend, I would like to be able to only program the "front-end": web interfaces that pull data from the database.
For the back-end, ideally, I would like to give my friend an off-the-shelf solution so she can enter images, albums, and associations between images and albums.
In the old days (I am thinking of DBaseIII), it was really easy to give interfaces to do that entry side of things.
Here is a crude approach I have tried. I have set up a view of the associative table joined to the parent tables, so it shows albumid, imageid (the PKs) and album, filename (associated fields in the parents) using this query:
SELECT albumid, imageid, album, filename FROM album_image axi
JOIN albums a ON a.`id` = axi.`albumid`
JOIN images i ON i.`id` = axi.`imageid`
The idea with this crude approach is that my friend would enter the parent PKs (albumid and imageid) in the associative table through the view, and that after hitting Insert, the full parent fields (filename and album) would be visible in the View for visual feedback. I have tried this view in three GUI tools: SQLyog (Win), HeidiSQL (Win) and Sequel Pro (OSX).
In Heidi and Sequel Pro, I have not found a way to edit the view.
In SQLyog, I can edit the PK fields (albumid and imageid) in the view, and the parent fields (album and filename) show properly when I hit "refresh". That's great. It works because even though the view shows three tables, we are only editing from one table. But I cannot delete a row as SQLyog doesn't know from which of the three tables we are trying to delete. On the other hand, in SQLyog, I able both able to insert and delete in a Query tab that contains the same query that creates the view, because in this kind of tab SQLyog allows me select the table being edited. So that works, but this workflow might start to be a little complex for my friend: she would have to open SQLyog, connect, open a saved query, select the right table to edit within the query, and make all the other right moves.
Wondering if any one knows an existing tool that is really good at making forms for MySQL---ideally a Windows or OSX binary. I will consider a web solution, but I am not interested in a framework---the key is speed of deployment, and if we went the framework route I would be better off making the interface with my own CRUD libraries. Again, I can code it, but my goal with these kinds of "quickie projects" is to focus my workload on the front end (web interface to the database), leaving the back end to an off-the-shelf tool.
Thanks heaps in advance for any insights. :)
Edit: I see that no one has mentioned Navicat or MySQL Workbench. I haven't tried either, wondering if someone knows off the top of their head whether they would do the trick.
I think what you're looking for is a form front-end for MySQL.
Since it sounds like you are more interested in binaries than web apps, have you looked into Microsoft Access? It can talk to MySQL and could be just what you need.
Open Office Base may not have quite the features you're looking for.
You already have the solution, your attempt at making things simpler is creating the complication.
There is no benefit to your friend in adding album images in a view if that view that only shows the filename and album title after they have entered the IDs and clicked Insert.
Before adding an image, your friend needs to know the album ID and the image ID. This information may not be in the view. She will therefore look at the album table and look at the image table to find this information, cross-referencing the filename with her own list of uploaded images.
Then, having written these two numbers down, she can insert a row directly into the album_image.
For visual feedback, she can check the frontend website.
It is true that a view showing the album name and filename would make deleting entries easier, but I would assume that images and albums are added much more frequently than they are deleted.
The ability to edit an associative table in a view that shows linked information, therefore, should not greatly affect your choice of tool. I could suggest tools, and phpMyAdmin is a logical choice, particularly if it is desirable to teach your friend computer skills that are widely applicable. It appears you have already identified some executable tools.
I imagine that you could add some additional hidden frontend views that could make your friend's workflow easier, such as a list of images and IDs that aren't in albums, a list of album IDs, or a view that shows the IDs. I do recommend you consider extending the frontend with a simple login and Edit options using your CRUD library, rather than devising a separate backend GUI.
I appreciate this is not an answer to the exact question, but it does resolve your problem.
I'm not sure if this will be helpful or not. I was hoping to find a UI with some eye candy/styling, but while searching I stumbled upon this:
https://blogs.oracle.com/MySqlOnWindows/entry/introducing_mysql_for_excel
As part of the new product initiatives of the MySQL on Windows group we released a tool that makes the task of getting data in and out of a MySQL Database very friendly and intuitive, and we paired it with one of the preferred applications for data analysis and manipulation in Windows platforms, MS Excel.
Like I said, not sure if it will help. I'm in a similar situation - low-tech, low budget client. The difference is my weakness in MySQL, but for me I just need a single table, so I think this will work.
There is no tool that will allow you delete such values from such a view, not for mysql, since For a multiple-table updatable view ... DELETE is not supported, see Updatable and Insertable Views
I guess you are looking for the equivelent of the Python based Django admin system which practically builds itself from analysis of the data structure.
Frameworks like Symfony, Cake and Yii have some of this built in, however I'm guessing that your database architecture may not be compatable as these types of systems normally require you to stick to strict naming conventions, but it's certainly worth taking a look.
Playful,
I already posted one answer, but this one is different enough to merit a seperate response, IMO.
Since you are looking for a simple, client-friendly solution, may I suggest Adminer?
http://www.adminer.org/en/?
Specifically, I used the Wordpress plugin here on a site recently:
http://wordpress.org/extend/plugins/adminer/
It provides pretty much full phpMyAdmin funcitonality. Very easy for the client, and if they want to, they can export the database as .csv and edit in excel, then re-upload. Just about everyone is familiar with editing in Excel, and they can make backups regularly.
Hope this helps!
J
You can very quickly and easily make a front-end for this type of use with Xataface. I find it very quick and useful. I would be happy to help you get going with it.
www.xataface.com
In my app many users, and they can add articles, articles can contain images, and all images stored in uploads folder, and by default any user can delete any image in folder, certanly its not good, whats is the best way to fix that
(For example store images in uploads//) or something like that?
Problem is - how i can separate user uploads?
Since you included the tag yii have a look at Authentication and Authorization - Yii framework. It has special support on this topic. Try to stick with your frameworks conventions to achieve what you desire first. This way you'll have a conssistent system and the power of frameworks' community.
Hie guys i am still learning cakephp so this question might be easy but im struggling. I have a view.ctp that is currently displaying a buyer's profile like personal details, in addition to this i also want it to display a profile picture for the buyer as well. I have a field in the buyers table called prof_pic which is using longblob data type. I can view the profile of the logged buyer, now i want them to view their profile picture and the personal details as well. How do i do this? Thank you
save image in folder
then you can easily use it ... resize or crop as you like ..
that's simple and easy way :)
You should consider saving your files in the filesystem instead of the database. Florian Krämer from CakeDC did a nice writeup of why to do this. In short:
Storing files in the database is in nearly all cases a bad solution
because when you get the file it has to go its way through the
database connection, which can, specially on servers that are not in
the same network, cause performance problems.
Advantages of storage in the file system:
Easy and direct file access, to parse them (csv, xml...) or manipulate them (images)
You don't need to install any additional software to manage them
Easy to move and mount on other machines
Smaller then stored in a DB
He started an interesting implementation of a plugin to do this. It makes use of the Gaufrette filesystem abstraction layer and makes working with files in Cake much cleaner. A way to scale Images to your needs with the Imagine plugin is also already provided and you're even able to host your images on Amazon S3 and the likes if you're running a high traffic site.
We have a web application that we're refactoring. We want to make an environment per version with different users (companies) that share the same codebase.
It know this is a somewhat simple question but I just want to make sure we make the right decision (according to webapp best practice).
Say companya.webapp.com points to /1.00/public
and companyb.webapp.com points to /1.30/public
I'm wondering what the best way is to store custom data from these users. Custom data could be uploaded documents, photos and also generated static data like PDF documents/invoices.
When I migrate a user to a different version I want his data to be available in the other version too. The documents also have a record in the database with the path description.
Would it be OK to do something like this structure:
/data/[companyname]/pictures
/data/[companyname]/documents
/data/[companyname]/documents/pdf
/data/[companyname]/documents/csv
/1.00/public
Sure, use whatever structure you like. There's no real "correct" answer, and it's very hard to do it wrong. Just make sure the permissions are properly set, so that each company can't read each other's files.