For image files, we generally save it in the server's hard disk, rather than stored in the database, just the path of the file is saved to the database, when needed, and then called after query. So we need to design a table to put the basic information of the picture.
A property is generally can have more than one picture, at the same time, according to the actual business qualification, a picture normal can only correspond to a property (avoid fake listings), so we in the design database, housing and pictures should be a one-to-many relationship. And our product demand is for the housing agent, a listing information on the site will certainly be repeated, the corresponding relationship between the property and the user is many-to-many relationship. Therefore, in order to facilitate user management of the picture, our picture Resource table should also be linked with the user, the corresponding relationship between the user and the picture resources should also be a one-to-many relationship.
Normal in the page, we will be in the same page to complete the basic information and image upload tasks, but the picture upload is generally in the <input type= "file" > control after the file is added, the entire large form before the submission of the image uploaded to the server to do processing, So the Avatar upload is done first, and then the general information submitted.
This is a problem: the two operations are step-by, how to correlate the two parts of the information, and also to prevent any unexpected situation in the middle, such as:
- Upload the image, the results of the listing in the middle of other reasons do not release or later release, this situation once more, it is bound to cause a lot of garbage accumulation.
- After uploading the image, the Web page is stuck and the page has to be refreshed, and the uploaded image information cannot be retrieved after the refresh, causing the user experience to drop.
- Image is a priority to upload, which means that the listing information has not been established, the natural database of the House ID has not yet, how to establish the relationship between the picture and the property?