How can I make a photograph database that displays the results of a query as some kind of image gallery? - database

I am taking a database design class and for a project want to make a database of my mom's digital photos for her. I haven't dealt in application up to this point, only theory, but I have Access. Therefore, ideal answers don't suggest non-database solutions and don't assume I know much about actual database implementation. Solutions specific to Access could also be a plus. I hope that precursor saves some time and effort.
Theoretically, my mom wants to see all photos of pets from '05-'07 in raw format, and she enters an appropriate query. I suspect I can handle it up to there. However, at the moment, the best I can figure out to do is to return a column of either attachments or OLE objects. 5 clicks per photo is not ideal. I need a faster way to present the images. Opening them all in a grid of thumbnails or as a one-click-slide-show would seem the natural fit, but whatever works. How can I accomplish this?
Less important but worth consideration is the fact that, at some point, it would be great if this same type of system could be implemented on the internet for all of the family reunion photos she has taken, but I will take what I can get.

Use one form to get parameters for the query. then use another form(more processing) or report(if printing) to show the selected pictures. I will not cover passing parameters but here are some links.
https://www.fmsinc.com/microsoftaccess/forms/openargs/index.htm
https://learn.microsoft.com/en-us/office/vba/access/concepts/forms-design/apply-a-filter-when-opening-a-form-or-report
There is a complication, in Access pictures are usually stored in the attachment type. the attachment column can hold many pictures in each record. So if we have a table called Pictures with an attachment type column also called Pictures, then each individual picture is actually stored under Pictures.Pictures.FileData.
So to display the picture query we use a form/report with default view set to Continuous Forms (displays many records or in this case pictures on the same page) then in the details section of our Display form we place an attachment control and bind that control to our filtered Pictures.FileData.
Format and add functionality to taste.

Related

WordPress : make categories automatically match according to external API Value

I'm managing a company website, where we have to display our products. We however do not want to handle the admin edit for this CPT, nor offer the ability to access to the form. But we have to read some product data form the admin edit page. All has to be created or updated via our CRM platform automatically.
For this matter, I already setup a CPT (wprc_pr) and registered 6 custom hierarchical terms: 1 generic for the types (wprc_pr_type) and 5 targeting each types available: wprc_pr_rb, wprc_pr_sp, wprc_pr_pe, wprc_pr_ce and wprc_pr_pr. All those taxonomies are required for filtering purposes (was the old way of working, maybe not the best, opened to suggestions here). We happen to come out with archive pages links looking like site.tld/generic/specific-parent/specific-child/ which is what is desired here.
I have a internal tool, nodeJS based, to batch create products from our CRM. The job is simple: get all products not yet pushed to the website, format a new post, push it to the WP REST API, wait for response, updated CRM data in consequence, and proceed to next product. Handle about 1600 products today on trialn each gone fine
The issue for now is that in order for me to put the correct terms to the new post, I have to compute for each product the generic type and specific type children.
I handled that by creating 6 files, one for each taxonomy. Each file is basically a giant JS object with the id from the CRM as a key, and the term id as a value. My script handles the category assertion like that:
wp_taxonomy = [jsTaxonomyMapper[crm_id1][crm_id2]] // or [] if not found
I have to say it is working pretty well, and that I could stop here. But I will have to take that computing to the wp_after_insert_post hook, in order to reaffect the post to the desired category on updated if something changed on the CRM.
Not quite difficult, but if I happen to add category on the CRM, I'll have to manually edit my mappers to add the new terms, and believe me that's a hassle.
Not waiting for a full solution here, but a way to work the thing. Maybe a way to computed those mappers and store their values in the options table maybe, or have a mapper class, I don't know at all.
Additional information:
Data from the CRM comes as integers (ids corresponding to a label) and the mappers today consist of 6 arrays (nested or not), about 600 total entries.
If you have something for me, or even suggestions to simplify the process, I'll go with it.
Thanks.
EDIT :
Went with another approach, see comment below.

Is it necessary to record the image paths in the database when it is associated with a unique item?

In my web application, there are several classes whose instances need an image (i.e., photo). Each of these instances can have only one image. Currently, my implementation is that when user creates a new instance, I keep the name of the uploaded file as it is, and record it in the ImageUrl field of the associated table.
I feel like this is unnecessary. I can just rename the image with the unique url of the associated instance, and I can implement the programming logic accordingly. For example, if a user's id is 145, then I can record it with this name: profilephoto_145. Later, when I need to display the user's photo, all I need will be the id of the user. If user uploads a new file, I can just overwrite the existing file with the same name.
I wonder if this makes sense assuming each instance will have one associated image, and there will be no need to keep track of the previous files. What is the common approach for this? Should I keep the full path for each image and keep their original names, or should I implement this renaming files with ID?
I can just rename the image with the unique url of the associated
instance, and I can implement the programming logic accordingly. For
example, if a user's id is 145, then I can record it with this name:
profilephoto_145.
Yes, you can do that. The general search term for this kind of thing is "tight coupling" or "coupling and cohesion". The concept applies in lots of different areas of software development.
Your underlying idea is that you'll always store one profile photo per user, and you'll store it by concatenating "some kind of path" and "profilephoto_" and user's id. The main problem is that any change to that idea requires changing source code. And changing source code has ripple effects.
The common alternative is to store the image file's name in a database. In this case, most changes to that underlying idea would require only a database update.
Programmers who have been around a while cringe a little when people start using words like always and never. Because we know that, given enough time, statements that use always and never with respect to software are always never true.

Show Opportunity related Contacts in Custom Object Field

I have the next issue.
I have a custom object called 'Application', and I have this requirement:
"Show all Contacts related to an Application. Create a field on Application object, must be read only".
I solve it with apex code. 'Application' has a lookup to Opportunity, Opportunity to Account, and all my contacts have AccountId, so this way, I get all the contacts using apex code in a trigger.
But, I've been ask to change this to a Formula field in Application object.
So, my issue is next. I'm not able to get all contacts with advance formula editor, because they're not part of any object. I have no master-detail relationship.
Does any one know how can I achieve this using configuration? I should not use apex code for this req.
Thank in advance guys.
I don't think you can do it.
In formulas / merge fields syntax there's no way to go "up, up then down" (Application -> Opportunity -> Account -> down to Contacts related list). There's also nothing that would let you loop through Contacts (and display what? Ids? Names? Emails?). Roughly speaking you can only go up through dots.
You might want to explore path of "cross object workflow" rules but I imagine that when I add a new Contact to Account it should somehow "spread itself" to all related Applications? There's no straight way to fire a workflow on delete too - so you'd eventually end up with inaccurate list.
I'd say trigger was a good solution. Maybe it ws unoptimized but if it has to be in a field - tough.
There might be a fairly simple way of achieving that by embedding a visualforce page within Application page layout.
This should be doable with pure Visualforce (so technically there will be no Apex code ;))
Something as simple as
<apex:relatedList list="Contacts" subject="Application__c.Opportunity__r.AccountId" />
would be a good start (if you want your own layout and not a rel. list - you should be still able to pull it off with <apex:repeat> or <apex:pageBlockTable>.
There's one BUT here: it's not a field, just a display trick. Forget about using it in reports, mobile applications etc.
Another way - would it be acceptable to be 1 click away from these contacts? You could make a report "Account with Contacts", filter it by Id of one Account and later use "URL hacking" to change the filter depending on from which Application you'll click it. This link could be either a formula field or a real custom button/link. Technically - it's pure config, no apex & VF.
You can read more about URL hacking at Ray Dehler's excellent post and specifically about dynamic Reports here or here.

Is this the right db design for the most flexible and modular CMS with user management in CakePHP?

I would like to ask you guys if you could review my database design. I think it is quite self-explanatory, but to be absolutely clear:
My goal is to make an application which has a super flexible user management (which is why the groups are in tree-form and the groups and users have a habtm relationship) and a super modular way to build pages (which is why the pages consist of widget-blocks).
The reason I made users and profiles separate is because the users table will not change and is only needed for authentication and authorization. However, the profiles table will change according to the wishes of the client. So it might not have a signature, but an avatar field instead. Or maybe it will be completely empty / not exist at all.
A widget could be anything, it could be a poll, it could be a piece of content, it could be a navigation, it could be a collection of comments, whatever.
The reason I chose to make subdomains, locales and layouts separate tables instead of just putting the names into pages is because I want to limit the options that are available to the client. Just because I have a three-columns.ctp in my layouts folder doesn't necessarily mean I want the client to be able to choose it.
Same goes for the widgets. And besides limiting choice, not every plugin, controller and action in my plugins-folder is a widget, so I need a table to clarify which are.
A block is a widget on a page which sits in a container (e.g. the right column in a 3 column layout) at a particular position which is decided by the index (lower index means higher).
So that's my explanation, what do you guys think? Is this as good as it can be? Or do you have (a) suggestion(s) to make it even more flexible and modular.
[edit] Oh and to be clear, the widgets will of course have their own tables to store the information they need to store.
Well, I think that everything is great except "profiles".
When you try to get data from a logged user:
$this->Auth->user();
I don't think that you will get data about "profiles" so you will have to find profile by $this->Auth->user('id') etc. I think that you should merge "profiles" and "users" tables into "users" table.
So when you want to save, let's say, "signature" you should just put it in $this->request->data; and call $this->User->save($this->request->data); and the signature will be updated.
EDIT:
You can leave it the way it is but, to get other data than user, you will have to put:
$id = $this->Auth->user('id');
$current_user = $this->User->findById($id);

Dynamically disabling menu based on database query?

So I'm not a programmer, but my friend is. He's trying to help me develop a web/phone app but we are stuck because I'm having trouble communicating to him an idea and he is having trouble understanding. One or both of us is a moron ;) Part of the problem is that I don't even know where to search for the answer cuz I don't know the specific search terms...believe me I've tried...and I've searched stack overflow as well. Here is the problem:
Short Question:
Websites (like hotel search) allow you to search for rooms by selecting checkboxes in certain categories (i.e. smoking/nonsmoking, stars, size of bed, near downtown, etc.). Certainly these sites are referencing a large database of hotels in a city.
How can you create a site so that as you check boxes (narrow your search), other options which are no longer available are dynamically "grayed out" or disabled on the fly so you cannot check those boxes. So if I were to check 4 stars and that excluded all smoking rooms based on the database, then the option to check "smoking" would be disabled.
The key to this is that the site is querying a database as you click boxes, then based on the results of that query (which is presumably many rows of data (a subset)), it is analysing that subset of data to determine whether checkbox options should be on/off, then dynamically "graying out" specific options that are no longer available. Once you got to only a single possible result, then the site would pop up the website for that hotel (or some other action).
What is this called? Where can I get more information on this. Any pointing toward the right direction would be tremendously appreciated.
Thanks so much in advance!
Roy
HERE IS AN EDIT TO ORIGINAL QUESTION...HERE IS AN EXAMPLE:
So here is my sample database. Each Column (i.e. AA, AB, AC) represents a checkbox. '1'= True, '0'= False, and '2'= Either. Therefore, if you click checkbox AA, then only the top three rows would meet the criteria of AA=True. So query would return the top three rows. The '2's could be either True/False so since they don't affect outcome, those checkboxes should be disabled and only the checkboxes CA,CB, & CC should remain choosable. If you then click checkbox CB, then result ZYX would be output.
Conceptually, How do you go from the initial click to the point where the database is queried and the results are used to dynamically change the menu. People have suggested javascript but i am not looking for a language. I am more looking for the concept. I was thinking that the query would return a new "temp" array with just the top three rows. Then each column of this "temp" array would be queried to see if it contained a '1' in any of the rows. If it did, then that button would be turned "ON". If it didn't then that button would be turned "OFF". Is this confusing? Am I asking for too much ;)
This sounds like javascript could help. For example, using jQuery, you can dynamically send queries to databases based on whatever you click on checkboxes, and then reload a particular section of the webpage. Javascript can also dynamically disable checkboxes.

Resources