Database relationships design JPA [closed] - database

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 4 years ago.
Improve this question
I have been wondering about how to design the relationships between entities in my app, I am kinda new to this. Can you help?
WHAT APP? - CONTEXT
I am trying to develop an app to help people track their expenses, calculate statistics etc., as a hobby project to train my poor skills in full-stack development. The idea is that a user logs in and can add an expense, for example a chicken bought for 3 $ and the app will calculate his expense stats based on repeated input.
WHAT DO I NEED TO FIND OUT?
I have done users registration and logging in and am now creating the "SingleExpense" entity class. I am wondering how should the relationship between the expense and the user look like in this particular use case.
Should the user have a Set of expenses as a field with #OneToMany annotation? But then whenever I fetch the user I will get all his expenses since forever, right? I might do the FetchType lazy or something, but I am looking for the cleanest, correct solution.
Should the Expense have the User as a field with #ManyToOne annotation? But then if I try to fetch all the expenses, the User objects will be fetched along right? And if I want to persist a new Expense I need to put the whole User object into the expense, yeah?
Or maybe it should be bidirectional for some reason?
I am very confused with that, I hope you guys can try and explain to me what works and what doesn't and why. Thanks a lot! Cheers!

For the reason you explained, you should probably not have a OneToMany, since It would probably never be a good idea to ever load all the expenses of a given user. And even if some use case needs to do that, a simple JPQL query can do that.
So that leaves the second option, which is the right one. A ManyToOne can be lazy, too. So fetching an expense won't fetch the user unless you start using the value returned by expense.getUser(). And regarding the storage of a new expense:
loading the user from the database, using EntityManager.find(), to store it in the new expense wouldn't be a big deal: loading an entity by its ID is extremely fast
but even then, you don't actually need to load the user from the database if you assume it exists: you just need to get a lazy reference to the user, which you can obtain thanks to EntityManager.getReference()

Related

Understanding Ionic [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am very new to ionic and still trying to learn. Few things I can't get a direct answers on this, hope for some help me. I went through few tutorials are articles, have an basic idea of ionic.
I am trying to develop a "group app". the group has 50 members.
I wish to publish event listings in the group app. Updating will be done
every week. So i can't exactly recompile this into apk whenever I do updating.
Also, I noticed ionic has a template that has login page. Where exactly does the username database stored?
If i need an admin section within ionic app, will it be possible? Whats the recommended method to do this?
If possible, I want this to do without any cost at all. I have a normal wordpress website that uses mysql database.
please help. thank you.
I am very new to ionic and still trying to learn. Few things I can't get a direct answers on this, hope for some help me. I went through few tutorials are articles, have an basic idea of ionic.
it is apparent from your questions, you've been reading recipe and not tutorials. They may have been labeled tutorials, but they were not. You are asking way too many questions, and the topics are too broad (wide).
To answer your question, in order
I am trying to develop a "group app". the group has 50 members. I wish to publish event listings in the group app. Updating will be done every week. So i can't exactly recompile this into apk whenever I do updating.
Your conclusion is based on faulty logic, and not understanding how Cordova works.
Also, I noticed ionic has a template that has login page. Where exactly does the username database stored?
Username and password storage is your issue, not Cordova's.
If i need an admin section within ionic app, will it be possible?
Yes.
Whats the recommended method to do this?
That's up to you. But understand you will be building it your self, likely from scratch.
If possible, I want this to do without any cost at all. I have a normal wordpress website that uses mysql database.
It is possible, but you will likely want to use a REST API to talk to the mobile App.
As you can see, my response appear to be vague, but that is because your questions are too broad.
I recommend reading this FAQ
Top Mistakes by Developers new to Cordova/Phonegap
If you have any further questions, I recommend following up on Google Groups Best of Luck.
I am trying to develop a "group app". the group has 50 members. I wish
to publish event listings in the group app. Updating will be done
every week. So i can't exactly recompile this into apk whenever I do
updating.
you can do this using ajax requests to server to get new events
and this is pretty easy by ionic using angular JS but it just need some time to try and read on how to make a restful ionic application
this will help you get the events from the database when the application opened
Also, I noticed ionic has a template that has login page. Where
exactly does the username database stored?
online database, just ready my answer to your first question
If i need an admin section within ionic app, will it be possible?
Whats the recommended method to do this?
yes it is possible but it is not recommended to do it in your public app
better to make web app for that
If possible, I want this to do without any cost at all. I have a
normal wordpress website that uses mysql database.
it will cost you nothing and you can use the MySQL database of your website
Good luck, you can make it, it just need some time and some searches

Creating custom order system [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 7 years ago.
Improve this question
The question i have is many fold.
So I work IT for this company. It’s a small company. Very small. They have an ancient ordering system that uses MSACCESS and was built in Visual Basic. I’ve been tasked with developing a new ordering system that processes orders as well as take in orders online.
I’ve created an order form in Excel with all the proper calculations that need to be made as sort of a foundation. I’ve found a service called SpreadsheetConverter that converts it to HTML or if I’d like Node.JS. But to be completely honest I have no idea what to do with Node.JS. I have some knowledge of VB and i’m (sort of) starting to understand databases.
My question is where would the best place to start if I wanted to build an application that can take in orders, store/retrieve customer data (autofill?), store order information into a database so i can retrieve them. The order system has to customly tailored to this company, they make Doors, so the calculations deal a lot with sizes and styles.
I have all the calculations i need. Basically where should i start if I want to build a UI, write simple code, and have it interact with a database. I’ve checked out Xojo, I have a Mac so i cant use Visual Basic. Where should i look to start a database?
Or is it possible to connect the Node.JS that spreadsheetconverter creates and connect it to something like Firebase?
I’m sorry if this all seems confusing, I basically don’t know where to start and a push in the right direction is all i need so i can narrow my focus.
Xojo might indeed be a good start for this.
Xojo includes access to a sqlite database, and you can add new records rather easily. You do need to know how to design and query an SQL db, though.
The biggest question is probably how to implement the user interface. This will be the biggest task. With Xojo, you can design it fairly easily, using its window layout editor.
Then you can either develop a monolithic desktop app, i.a. a Mac or Windows app that runs and maintains its database all on the same, single, computer. Or, if you want to allow multiple users access the database from different computers, consider writing a Web application in Xojo, which will be used through a web browser then. Most code will be the same, but testing will be a bit more complex and slower for a Web app, probably.
You would have to re-implement all your calculations in Xojo, though, as Xojo has no way to use or import Excel sheets this way.
Also, have a look at FileMaker. I have never used it but it may fit your needs.

How do database driven blog-style websites work? [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 5 years ago.
Improve this question
Before I start: I know this is a very broad question, but it is the best way I could phrase it, I have searched around a lot and can only seem to find generic explanations. I searched SO and didn't find much. I have also skimmed through some pages in the wordpress codex, and didn't find anything really useful.
I would like to create a simple database driven blog-style website, it will really only consist of stories (their title, date, content, etc), I just began teaching myself web development and my idea of how database driven websites work has proven to be completely wrong. I figured you would always need a file connecting to the database for each article, but the more I read I learn about mark up being generated on request, and so on, so the actual /year/month/day/article doesn't actually have to exist on the server, or that may be wrong, that is why I am here.
As I said I cannot find much on this topic that isn't a generic graphic of a server interacting with a web page. How does one go about creating a database driven website of this style? Are the files/directories not actually on the server but only created on a case by case basis as someone requests it? If so, then why can you type out a complete url and it be there with out throwing a 404? I have a lot of questions, really all I need is a strong explanation of how these sites work, code examples, and so on. Could someone explain how they work or point me to information (recommended articles, examples or books)?
EDIT: Please don't recommend a framework, I want to understand how these sites work and build one myself.
It's actually quite simple. Wordpress's index page calls wp-blog-header.php. That file calls for other files, and those files call for other files. It goes on for some time until all the contents of the page are actually loaded.
The databases come in when you start thinking about having users. Obviously the user information is stored in the database. Beyond that, Wordpress keeps post titles, dates, and other information in the database for easy loading later on.
Comments are also stored in the database. Each comment is associated with a number, and in the database, just like the posts, the dates/times as well as the usernames associated with the comments are kept.
Further exploration in the actual Wordpress files will reveal a lot of interesting features.
You might want to check out Django. It is an open source Python web framework that provides a lot of the functionality you are talking about. It also has a lot of very good high-level documentation with even a free e-book. It is centered a bit more on newspaper type sites than blogging, but most of the same principles apply. If you are new to python and like to use IDEs I would recommend checking out PyCharm. It has tight Django integration and makes for simple project setup and debugging.
Generally speaking, you'll use a framework that will take input parameters (year/month/day/article), run some code to fetch data from the database, and dynamically create the webpage. There isn't an actual .html file sitting on the webserver. One of the most popular frameworks to do websites like you're describing is Ruby on Rails, which makes it incredibly simple to do.

Planning a database app [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I am in the planning stages of a database app for personal use. I have a good bit of the database structure planned, but as I think about how I'm going to write the program, it made me wonder if I'm doing this in the right order.
Which should I be planning first, the db structure or the classes?
I think designing your data model first is a very good idea.
If the app is to be database driven it is a good idea to have an solid understanding of what your data model is going to look like before even attempting to write any code.
You can still conceptualize how you think the classes may look as your thinking about your data model. Keeping this in the back of your mind as you determine your requirements will help when you begin to write some code as well.
Of course, as you begin to write code you will probably have to revisit your data structure, so it is an iterative process, but good planning at the onset of the project is a good idea.
I think you will get a differnt answer from data centric poeple vice application centric people. Personally I always start with the data but an application programmer would probably start with the classes.
In reality, I think you need to work on the two at the same time.
They most often develop together, although it's often easiest to start designing the basic structure of the database, and then move to the code. You'll find that depending on the size of your application the database will change frequently along the way to final product.
I typically plan as best I can, then I start creating the database per the planning/design specs I wrote for myself.
Then, I use something like Linq-To-SQL to generate some basic DAL classes -- wrap those in a repository class that manages most of my CRUD situations.
Depending on the complexity of the app, I then write a GUI which consumes the repository directly (quick/dirty) or I write a domain logic class (and potentially Data-Transfer-Objects or dumb POCOs) which wraps up the functionality in the repository.
Obviously, the best planning misses things, so make sure you take in to account that you'll have to go back and add fields, change types, add relationships etc.
If the purpose of your system is to store, retrieve and report on data, then I would say by all means it is appropriate to design the database first.
If, on the other hand, the purpose of the system is to implement a business process or processes using software, then it will often be more efficient to design the "domain model" first, modeling out the business process into objects/classes, then determining how to persist them to/from a database later.

UI Advice: how to design a form with a lot of data [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'm re-writing an app that is a data-entry tool. The existing app is in Access and consists of a form with multiple grids, with each grid containing many columns that requires the user to scroll horizontally in order to view columns.
The current grids on the form are layed-out heirarchically in parent-child relationships. Top grid represents projects, grid below that represents the SKUs in the selected project, the grid below that represents season data (pricing, shipping info, etc) for the selected SKU above.
I'm looking for advice regarding good UI design principles for this kind of app. How do I design a form that gives the user the flexibility to see all columns for the data on the form without needing to scroll so much?
What are some good online resources for UI principles for business apps?
Thanks!
What I've found to be a general rule of thumb that helps to develop aesthetically pleasing user interfaces is the notion of only presenting as much as is needed for any given task.
One of the approaches we can take in designing forms is to focus the user's attention to the task or function at hand by centering controls on a horizontal axis.
Culture, too, plays a major role in the acceptance of the programs we write. For instance, in Western culture, we read from left to right and from top to bottom. Therefore, programs targetted for a Western audience should ideally follow that same design principle.
Here's some basic principles that will help
use friendly words and terms over obnoxious and demanding tones:
"The file could not be found at the location 'c:\temp'" as opposed to "A required file could not be found please fix the error."
single color schemes that apply to the overall look and fonts
common control layout on all forms presents
follow the design guidelines generally employed for the platform you are targetting
References
Here is some reference material to help you on your own unique path
(Windows) User Experience Interaction Guidelines
(Apple) User experience guidelines
Windows design principles
(Windows) Some design pointers
To summarize, I've found that overwhelming the user with all the information he/she might ever need to perform a simple data entry is not really an ideal way; rather progressively presenting functionality and the tools to do what they want is, to me, a much better alternative.
As always, place youself in the user's position: "Do I like what I see? Does it make me happy to work with it? Is the program too restricted? How can I make task X much easier to perform?"
usability.gov is a great resource for UI design. Also, check out wufoo.com, which is a form hosting website. Their blog is chock-full of interesting research on usability and form design.
This site may help you out: http://www.jankoatwarpspeed.com/post/2009/02/18/How-to-deal-with-large-webforms.aspx. Big points there being tabs & collapsible regions.
Additionally, if you don't necesarily need to show all of those columns horizontally, you can present them when the user clicks the entry to view more details. I typically prefer to show the critical information, and then require the user to view more details if they need specifics.
As Mike mentioned, "the notion of only presenting as much as is needed for any given task"

Resources