Storing images and structured data together (Google Cloud Platform)
I am building a cloud service with Google Cloud Platform but I don't have much experience using it (yet) My service will, among other things, store structured entities with properties such as a Name, Description etc. However, I also want each entity to be associated in some way with a collection of images which could have dozens or even hundreds of images. Looking at the storage options GCP offers the structured nature of my data would suggest I should use Datastore and the images being 'unstructured' should use regular Storage (probably stored in folders to keep images from a particular entity together). My question is a) is this a reasonable approach for my use case? if so b) How do I link the two things together? or if not b) What is the best way to store these?
Your approach sounds OK to me, I'd do it the same way. As for linking the datastore structured entity to the images an alternate, more scalable approach to that suggested by Andrei Volgin would be to have multiple mapping entitites - one per associated image, containing as properties: the datastore structured entity's key (or key ID) the storage name/location of the image The advantages of such approach (especially when the number of images associated with one structured entity is high) are: no 1 write/sec limitation on adding/deleting images for the same structured entity no contention on the structured entity itself when trying to obtain image locations from multiple simultaneous requests no performance degradation with the increase of the number of images associated to a structured entity (due to the increased entity size needed to be serialized); the size of the structured entity remains small The disadvantage would be that you need an additional query to obtain the info about the images associated to a structured entity. These mapping entities can contain additional structured image-related information, if eventually needed.
Your Datastore entities may have a property that contains a list of image file names. Assuming that you put each image in a "folder" that represents the entity ID/Name, you can display an image by simply calling (for example): "https://storage.googleapis.com/MY_BUCKET/" + entity.getId() + "/" + IMAGE_NAME; In several of my projects I need to store more data about each image, e.g. its order, orientation, and size. In this case I create an entity to represent each image in Datastore. In some cases I use embedded entities - for example, a product entity contains a list of embedded entities representing images related to this product. This approach allows me to display a list of products with images without an extra query to get images for each product.
I would use two different kind of entities. ex. Album and Images and organize them by using the ancestor path like a file structure. Then I could easily add a Comment entity kind as child of Images. Example of 2 entities [TaskList:default, Task:sampleTask] $taskKey = $datastore->key('TaskList', 'default') ->pathElement('Task', 'sampleTask'); Read more about Ancestor paths
What does _ah mean in Google App Engine?
Spring Roo with GAE error on most basic tests
Running a web crawler for selected sites on google app engine?
Many-to-many relationship modeling in google app engine
Appengine: ClassCastException in query with string of leng
How to integrate user quotas?
Restlet that works on localhost throws NullPointerException when deployed on GAE
No module named Crypto.Cipher on local mac AppEngine
Should I use a GZIP compression middleware or not?
AppEngine vs. sendmail space problem
nosetests 'cannot import name mkdir'
What is the benefit / usage of a AppEngine remote procedure call
How use AppEngine's Datastore Admin: Copy to Another App Feature
Balancing server/client load for autocompletion search
AppEngine: Reading values/settings from app.yaml
Google App Engine - inline/iframe log-in