storing a tuple in sql or gql database? - google-cloud-datastore

this might be a really simple question, but im struggling with it.
could you help me find a way to store two pieces of form data in the GAE datastore, as a tuple?
thankyou.

You need to store it as two separate properties.

You can store them as two separate properties, or, if they are of the same datatype, you can put them in a ListProperty.

Related

How to properly use the create table in DynamoDB?

This is a conceptual question, I am a developer who is familiar with Mongo & Postgres. In both of these DMS, you never have to create a table before using it. I don't really know how it works under the table but I create my Schema's in Mongo or my classes in Postgres (I use SQLAlchemy ORM) defining the structure of my different tables.
With DynamoDB I understand I can do the same but before adding an item/column into the table I need to check if the table is created? I don't really get how that works. Do I just create the tables the first time I create my db instance and if I add more tables I just create them once??
I understand the reasoning behind DynamoDB needing me to create the tables explicitly because they will allocate a certain amount of space in anticipation of the items that will be stored there but I have looked around and not really found a best practice or advice on when I should be creating new tables in DynamoDB?
Think of it this way: the DynamoDB table is the same as your Postgres database, not your Postgres tables. It's a piece of infrastructure that your service depends on, so you need to create the table at the same time you would create your Postgres database.
Also be sure to understand that unless you're doing some very, very complex thing, dynamoDb is intended to be used with 1 table per service. So if you're thinking "I need 4 tables", I'd suggest looking at this great aws video.

How I manage the common reference data in Corda

Wondering what will be a good way to manage common reference data used by all nodes / specified nodes in Corda? One of the example will be a Contract Type or Legal Entity Name, which are the common reference data, shared by specified nodes.
I was thinking Oracle can be the solution, but after the study, seems Oracle is not be appropriate as we only need to get the list of reference data and can be quite frequent.
Other solution I have in mind is to have a centralized place to manage such data and can be obtained thru API. Appreciate anyone can help on this. Thanks.
Kwan
Reference data should generally be included in the form of attachments.
The theory is here, and you can read about how they work here.

2sxc Create an SQL view of an entity's values

I'd like to work with data from 2sxc in Excel (for reporting/analysis purposes). Is it possible to create a query that would create a normal looking view with the fields?
Thanks.
Technically this can be done using standard sql, but I can't provide a quick example. You basically need to do pivots. Alternately you could create a html-view and open/link that in excel, this is probably much easier to do.

Which one to use? EAV or Blobs in the database?

I am currently working to rework the data system of our application. Basically, it is designed so that people can add all the custom fields they want, with only a few constant/always-there fields.
Our current design is giving us plenty of maintenance problems. What we do is dynamically(at runtime) add a column to the database for each field. We have to have a meta table and other cruft to maintain all of these dynamic columns.
Now we are looking at EAV, but it doesn't seem much better. Basically, we have many different types of fields, so there would be a StringValues, IntegerValues, etc table... which makes things that much worse.
I am wondering if using JSON or XML blobs in the database may be a better solution, specifically because in most use cases, when we retrieve anything out of these tables, we need the entire row. The problems is that we need to be able to create reports for this data as well.. No solution really makes custom queries look easy. And searching across such a blob database will surely be a performance nightmare when reports are ran.
Each "row" needs to have anywhere from about 15 to 100(possibly more) attributes/columns associated with it.
We are using SQL Server 2008 and our application interfacing with the database is a C# web application(so, ASP.Net).
what do you think? Use EAV or blobs or something else entirely? (Also, yes, I know a schema free database like MongoDB would be awesome here, but I can't convince my boss to use it)
What about the xml datatype? Advanced querying is possible against this type.
We've used the xml type with good success. We do most of our heavy lifting at the code level using linq to parse out values. Our schema is somewhat fixed, so that may not be an option for you.
One interesting feature of SQL server is the sql_variant type. It's fully supported in .NET and quite easy to use. The advantages is you don't need to create StringValue, IntValue, etc... columns, just one Value column that can contain all the simple types.
This very specific type favors the EAV option, IMHO.
It has some drawbacks though (sorting, distinct selects, etc...). So if you want to use it, make sure you read all the documentation and understand its limit.
Create a table with your known columns and "X" sparse columns using a sequential name such as DataColumn0001, DataColumn0002, etc. When there is a definition for a new column just rename a column and start inserting data. The great advantage to the sparse column is it is indexable.
More info at this link.
What you're doing is STUPID with a database that doesn't support your data type. You should work with a medium that meets your needs which include NoSQL databases such as RavenDB, MongoDB, DocumentDB, CouchBase or Postgres in RDMBS to name several.
You are inherently using the tool in a capacity it was neither designed for, and one it specifically attempts to limit you from achieving success. NoSQL database solutions frequently use JSON as an underlying storage because JSON is inherently schemaless. Want to add a property? Sure go ahead, want to add a whole sub collection? Sure go ahead. NoSQL databases were in part, created specifically to remove rigid schema requirements of RDBMS.
2015 Edit: Postgres now natively supports JSON. This is a viable option for RDBMS. My answer is still correct that you need to use the correct tool for the problem. It is a polygot persistence world.

How do I do this in Drupal?

Im currently evaluating Drupal to see if we can use it to replace our framework. My problem is I have this legacy tables which I would want to try to reflect in Drupal. It involves a join table. There's quite a lot of this kind of relationship in our existing web app so I am looking for possible ways to solve it.
Thank you for your insight!
There are several ways to do this, and it's hard to know which is best with no context about what you're actually doing with the data, but here are some options:
One way to do this is to make a content type representing each table (using CCK) with the foreign keys represented by type-specific node reference fields. Doing everything as nodes gives you a bunch of prebuilt functionality around nodes, but has a bit of overhead you may want to avoid.
Another option is to leave your database just like it is now. Drupal can do direct database queries, or you can use Data to expose your tables to Views.
Another option, if those referenced tables really only have 1 non-ID field, is to do the project_companies_assignments as nodes and do the other 3 as taxonomies. But this won't work if those are really more complex entities, and wouldn't be very flexible if they might become more complex.
What about using hook_views_api and exposing your legacy tables in hook_views_data? i tried something like this myself - not sure if that is what you want...
try and let me know if that works for you.
http://drupalwalla.blogspot.com/2011/09/how-do-you-expose-your-legacy-database.html
Going with Views and CCK, optionally with the additional Data module has one huge disadvantage: it comes with complexity.
My preferred alternative, is to write your own module. Drupal offers little help wrt database abstraction, it comes not with a proper ORM or such. But with some simple CRUD functions for the data in the database, a few simple forms in front, and a menu-callback with some pages to present the data, you can -quite often- get your datamodel worked out much faster then going the route of the overly complex, often poorly documented CCK and views modules. KISS.

Resources