When use a database? [duplicate] - database

This question already has answers here:
Storing Images in DB - Yea or Nay?
(56 answers)
Closed 3 years ago.
I'm making a web-site for learning-purpose and in this site I'm planning to add some pictures.
My (maybe stupid) question is, when should you use a database for pictures? Like, is there at a specific amount of pictures that calls for a db, or are db's only for storing other types of information? Maybe db's should be used as soon as you don't want to store everything on your computer?
I was linked another page for a similar post below (my post would be a duplicate). That post is from 2008 and is mostly about SQL. Are there any new thoughts on the subject today, and is there any preferred database for storing different types of data?
Thank you

we can divide website into 2 types :
Static website
Dynamic website
Static Website :
which is created using Html , Css , Javascript , Jquery
normally have less number of pages (5 to 10)
it is just used to display information written in HTML page
Example : Simple Website with common pages like homepage,aboutus,contactus, and 2 - 3 pages with simple information
Dynamic Website :
generally no limit of pages
used to load data/information dynamically
which is build using frontend plus backend and database
database : database is used to store values into appropriate table/document
example of databases :
MySQL,Sqlite,Oracle,SQL,PostgressSQL,MongoDB,Redis etc..
backend : it is server side code written to perform CREATE, READ, UPDATE, DELETE called as CRUD operations into Database and other operations using different programming langauges
backend done with programming Languages :
PHP,Java,NodeJS,Python,Go,Ruby ...etc
frontend : it is used to make http request to backend function and display data on page as per data provided by backend
here frontend can be using HTML,CSS,Javascript,Jquery,Ajax or modern
frontend technologies like : AngulerJS , ReactJS , VueJS
Example : Blog Website, Ecommerce Website, and many more ....

Related

Use .json file or database for static data?

I am building a web app using nodeJS with an angular based frontend and a Firebase/AngularFire2 backend. I have a list of about 80 cities and couple of details about each of them that I need to display with checkboxes for the user.
Should I save them as a json object in a .json file on the server and call it, or just store it in my Real-time Database and query it? Are there any speed/memory benefits to either?
There are two scenarios :
1.Your task is search oriented. You have to query the data and manipulate it. Memory management is key issues for you. You want some complex searching methods on your data. Then go for the database.
2.Your task require whole data at a time. You don't need to worry about memory management. Then directly load the data from file. Obviously this method will save the connection making time with your database. It will work as simple as file streams. [suggested for your case]

Best implementation (folder structure) of SPA with Yii2 and AngularJS 2 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
As you know angular 2 is in beta right now.
Generally is it good to start a single page application (SPA) using angular 2 and yii2 as a RESTful API (for backend services)?
Assuming this:
how could be the structure?
What is the best implementation of this? (with sample)
Update:
Sorry, but I'm not good in English. I think the usage of implementation was wrong. I mean what is the best folder structure for using yii2 and angular 2 as a SPA like this repo.
Last Update:
As #SalemOuerdani told and mentioned I think that this link is my answer. maybe my question is a duplicate! Sorry for that!
The Yii2 quick start example for REST gave those endpoints as example:
GET /users: list all users page by page;
HEAD /users: show the overview information of user listing;
POST /users: create a new user;
GET /users/123: return the details of the user 123;
HEAD /users/123: show the overview information of user 123;
PATCH /users/123 and PUT /users/123: update the user 123;
DELETE /users/123: delete the user 123;
OPTIONS /users: show the supported verbs regarding endpoint /users;
OPTIONS /users/123: show the supported verbs regarding endpoint /users/123
Well that is REST. It doesn't matter which tool or framework to use. You can rebuild the same using Ruby, C or NodeJS and steal being the same app. Just have it in seperate folder or server and call it backend or server while it retreives data from DB or whatever else to answer the previous URI's.
The frontend in this case is the other app built with whatever language stored in a different folder or server that when it does a request to GET /users will expect a json response. when it does some edits on user 123 and send it back to server within PUT /users/123 it will expect the server to responde with a 200 response to know that it has been saved to database or a 422 error for example if validation fails.
My advice is to work with both tools as separate things. I don't recommand changing Yii's default rooting. The commun point between both should be the standards and concepts or architecture you did decide to implement or design for your HTTP requests.
More answers and a valid structure for Yii and angular may be found in the following:
What exactly is RESTful programming?
Yii2 + AngularJS in a single application - how?
How could be the structure?
There are alot of github repo's available for the best structure of angular2. you could refer to those for structure of your app,
this one is good repo i had ever found here:-
https://github.com/mgechev/angular2-seed
here is my repo you can refer to this too...
https://github.com/MrPardeep/Angular2-DatePicker
What is the best implementation of this? (with sample)
For implementation there are alot of tutorials and articals are there on the internet, but i personaly suggest to refer from the
official website of angular first.
https://angular.io/guide/quickstart
http://angularjs.blogspot.in/2015/12/angular-2-beta.html
http://www.angular2.com/

Options for Filtering Data in real time - Will a rule engine based approach work?

I'm looking for options/alternative to achieve the following.
I want to connect to several data sources (e.g., Google Places, Flickr, Twitter ...) using their APIs. Once I get some data back I want to apply my "user-defined dynamic filters" (defined at runtime) on the fetched data.
Example Filters
Show me only restaurants that have a ratting more than 4 AND have more than 100 ratings.
Show all tweets that are X miles from location A and Y miles from location B
Is it possible to use a rule engine (esp. Drools) to do such filtering ? Does it make sense ?
My proposed architecture is mobile devices connecting to my own server and this server then dispatching requests to the external world and doing all the heavy work (mainly filtering) of data based on user preferences.
Any suggestions/pointers/alternatives would be appreciated.
Thanks.
Yes, Drools Fusion allows you to easily deal with this kind of scenario. Here is a very simple example application that plays around with twitter messages using the twitter4j API:
https://github.com/droolsjbpm/droolsjbpm-contributed-experiments/tree/master/twittercbr
Please note that there is an online and an offline version in that example. To run the online version you need to get access tokens on the twitter home page and configure them in the configuration file:
https://github.com/droolsjbpm/droolsjbpm-contributed-experiments/blob/master/twittercbr/src/main/resources/twitter4j.properties
check the twitter4j documentation for details.

Multiple data sources: data storage and retrieval approaches

I am building a website (probably in Wordpress) which takes data from a number of different sources for display on various pages.
The sources:
A Twitter feed
A Flickr feed
A database on a remote server
A local database
From each source I will mainly retrieve
A short string, e.g. for Twitter, the Tweet, and from the local database the title of a blog page.
An associated image, if one exists
A link identifying the content at its source
My question is:
What is the best way to a) store the data and b) retrieve the data
My thinking is:
i) Write a script that is run every 2 or so minutes on a cron job
ii) the script retrieves data from all sources and stores it in the local database
iii) application code can then retrieve all data from the one source, the local database
This should make application code easier to manage - we only ever draw data from one source in application code - and that's the main appeal. But is it overkill for a relatively small site?
I would recommend putting the twitter feed and flickr feed in JavaScript. Both flickr and twitter have REST APIs. By putting it on the client you free up resources on your server, create less complexity, your users won't be waiting around for your server to fetch the data, and you can let twitter and flickr cache the data for you.
This assumes you know JavaScript. Once you get past JavaScript quirks, it's not a bad language. Give Jquery a try. JQuery Twitter plugin Flickery JQuery plugin. There are others, that's just the first results from Google.
As for your data on the local server and remote server, that will depend more on the data that is being fetched. I would go with whatever you can develop the fastest and gives acceptable results. If that means making a REST call from server to sever, then go for it. IF the remote server is slow to respond, I would go the AJAX REST API method.
And for the local database, you are going to have to write server side code for that, so I would do that inside the Wordpress "framework".
Hope that helps.

Need advice for my Server part

I'm stuck on my server part.
I thing it would be fine if I make an REST architecture but I'm not sure.
My application is that an identitied user edit his name, age, hobbies...and I want to stock all the informations of all the users on my data server. Then, I could send the information of a user to another in a ListView with an adaptater.
Any idea to help me?
Thanks in advance
I have recently added a series of posts to my blog that may help. It covers creating a RESTful service using Java EE technologies on the GlassFish server. The example produces consumes XML, but could easily be adapted to handle JSON.
Part 1 - The Database Model
Part 2 - Mapping the Database Model to JPA Entities
Part 3 - Mapping JPA Entities to XML using JAXB
Part 4 - The RESTful Service

Resources