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 9 years ago.
Improve this question
What is the starting point in designing a database? UML or Java?
Eg: If u are using both java and UML for designing a database, how do you beging?
First with UML design and then Java script? Or the other way?
You need to start with Entity-Relationship diagram.
An ER model is an abstract way of describing a database. In the case
of a relational database, which stores data in tables, some of the
data in these tables point to data in other tables.For instance, your entry in the database could point to several entries for each of the phone numbers that are yours. The ER model would say that you are an entity, and each phone number is an entity, and the relationship between you and the phone numbers is 'has a phone number'. Diagrams created to design these entities and relationships are called entity–relationship diagrams or ER diagrams.
Microsoft Visio is one of the commonly used tool to do that.
The starting point is the Diagram you will make to describe the relationships between the tables.
In your project you will have to have two different diagrams, one for the Java classes and another one for the database tables.
EDIT
I would recommend you to take a look at this link Object-relational impedance mismatch, to make sure you will not confuse both schemes.
Definitely not the otherway... First design then validate the design then comes JAVA.
So use the Data Modeling (using ER diagrams) and then (if applicable) Object Modeling. As mentioned above Visio is a good tool, also you can use a pen-paper designs.
And when you talk about Data Design, ORM is very important to keep in mind.
Related
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 3 years ago.
Improve this question
I have difficulty in implementing GraphQL in a java project as a part of updating it. I'm trying to connect an entity (which uses the Hibernate ORM to map to different databases) to a GraphQLObjectType . Any suggestions how can I accomplish this? Can I omit the GraphQL database configurations if so?
There're multiple options here.
It's probably best to not even map an entity directly . Entities are direct representations of the DB and, as such, should probably not be directly exposed, but wrapped into DTOs (maybe allowing pagination, flattening relations, or whatever is appropriate) instead.
If you just need to map the class (entity or not) to a GraphQLObjectType, graphql-java-annotations is the simplest (and most limited) route (check the status of this project first, it was on a hiatus for a while)
If you want to expose the entire entity graph through GraphQL, graphql-jpa might be your best bet (as Sriram suggests), as it's intended to do exactly that, while also adding pagination, aggregation and sorting
If you want to automatically expose not only an entity/DTO class, but also the operations upon it (e.g. an arbitrary service class), look at graphql-spqr (I'm the author of that project)
If you already defined your entities using JPA/Hibernate, try this:
https://github.com/jcrygier/graphql-jpa
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 8 years ago.
Improve this question
Problem
Given a technology specific Java Model T, I want to have:
a technology agnostic model A to use in my code (i.e. the M in MVC).
a persistence mechanism P to store my model A.
Approach
Currently I have figured out some options:
Option 1:
Manually create the classes for A
Manually create the code to translate T to A
Manually create an XSD of a third JAXB-Model J
Generate JAXB-Model-Classes from J
Manually create the code to translate A to J
Use JAXB to automatically save J
When loading all translations have to be created into the other direction manually.
Advantage: can't see one. Thats my question :)
Disadvantage: most developing effort of all Options.
Option 2:
Manually create an XSD of a JAXB-Model of A
Generate JAXB-Model-Classes for A
Manually create the code to translate T to A
Use JAXB to automatically save A
When loading the translations has to be created into the other direction manually.
Advantage: Low developing effort. A can be persisted directly.
Disadvantage: I read, that it's a bad Idea, to use JAXB-classes as modell. But I don't understand why.
Option 3:
Manually create the Model of A as an eCore-Model
Generate the classes of A from the ecore-Model
Manually create the code to translate T to A
Use eCore-resources to automatically save A
When loading the translations has to be created into the other direction manually.
Advantage: Low developing effort. A can be persisted directly.
Disadvantage: None?
Looking at the advantages and disadvatages, I it seems like I should definitly use eCore instead of JAXB.
Question
Is it really that clear, to use eCore? Or are there advantages/disadvantages I should also think about?
Is here an easier way to translate from the technology specific model T to the technology agnostic modell A. Currenly I have to implement A and the translation A <-> T myself. Some easier way would be nice.
You could use JAXB to convert your Model A to XML. This leverages the Java first aspect of JAXB instead if the schema first in your question.
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 8 years ago.
Improve this question
I have a dilemma on how to implement this requierement:
Let's say I have the following Contact classes
Student,
Tutor,
AdminStaff.
I am not sure what is the best way to structure it in DataStore:
shall I have one Contact entity which will contain shared fields and also corresponding extra fields for given type
or shall I have three separate entities
first approach allows me to search through all my contacts, and the second is to avoid extra filtering when I just need contacts of certain kind.
However I have one more requirement which I am not sure how to accommodate with any of these approaches. What if I have contact with multiple personalities e.g. Tutor and AdminStaff. This suggests I have a separate Contact entity and link to its various personalities. So for the above example I would have data about that person kept in three entities Contact,Tutor,AdminStaff.
I would appreciate for any suggestions
Regarding your concern about searching over all your contacts - even if you have 3 different entity types, I think you could still create an index that would allow you to search over all contacts.
I don't know how many attributes there are that are unique to the different contact roles, but I'd be worried about creating a single mega-class/entity that encompassed them all - it could be a very big and messy class.
And, as you have indicated, your final requirement does make things more complicated. It suggests that perhaps you should have a single contact class/entity for all roles, and then create class(es) for the 3 roles that can be #embed'ed into to the contact entity.
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 9 years ago.
Improve this question
So, I'll be looping through a data base and there will be a bunch of campaigns. Each campaign will have some demos and some sites where certain conditions are satisfied. I want to plot some graphs for the data corresponding to all the campaigns, sites and demos. I was thinking of using java, first getting the campaign, site and demo combinations where the conditions are satisfied and then looping through all of them, running individual queries based on their values and plotting the graphs using maybe, GNU plot. My questions are -
Is there a better way to achieve this (with minimal queries).
If I do do it this way, I first have to store the information.
I was thinking of storing the campaign ids in an ArrayList of Integers, the demos for each campaign in
ArrayList<ArrayList<Integer>>
and the sites for each campaign in
ArrayList<ArrayList<Integer>>
Is there a more efficient way of storing this information?
I'd recommend creating a new class to hold your campaign data and storing references to each object within an ArrayList if you need to keep a handle to them in memory (may not be necessary).
From a purist point of view, the class should be backed by a Data Access Object (DAO) and Plain Old Java Object (POJO) to manage database access and storage in memory but if this is a simple prototype then I wouldn't worry too much. I'd also recommend a utility class to convert/write your chart data - all accessible from your Campaign class.
The Campaign class should also be able to work out whether your conditions are satisfied - and if it's worth generating those charts.
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 9 years ago.
Improve this question
I am new to cassandra. I have to write an application that uses cassandra. I wanted to know which one will be better for me so that i will not face much problem in future. Which api should i use for my application.
Sunil, you're addressing a reasonable question, and I think it's wholly appropriate that you've asked it before coding away at a problem. You might reach a more widely accepting audience if it were phrased something like, "What are the pros and cons I should look for between these two approaches to help me decide between them?"
The Hector client supports a programmatic interface for communicating with Cassanda, as well as a way to parse CQL statements, so your choice isn't necessarily between Hector and CQL, but more like programmatic vs. CQL, or a combination of the two. You could face that same question even if choosing between Hector and Astyanax clients.
Reasons to choose CQL:
CQL is easy to store, retrieve, and compare revisions.
CQL is easy to read and reveiw, especially as DDL.
CQL is easy to log for troubleshooting and auditing purposes.
Developers with a history of RDBMS may acclimate more quickly to CQL, reducing training time or increasing a pool of candidates for hire.
Community development is trending toward JDBC-like handling of CQL.
Reasons to choose Programmatic:
[AMENDMENT]
It appears some of my knowledge was outdated. Based on jbellis' comment (the Jonathan Ellis, I presume), CQL is currently more performant than thrift, and also supports prepared statements. I'm at a loss for a good argument against a CQL-based approach.
Another completely different option is playOrm so that you can do joins with no limitations. playOrm allows you to do "scalable JQL" which looks like the below. You only need to decide how to partition your data.
#NoSqlQuery(name="findJoinOnNullPartition", query="PARTITIONS t(:partId) select t FROM TABLE as t INNER JOIN t.security as s where s.securityType = :type and t.numShares = :shares")