Can I store some business metadata per field? other words, I have some business metadata I want to specify per field is that possible in Avro?
Yes, you can add additional key-value pairs to a field. Quoting the Avro specification:
Attributes not defined in this document are permitted as metadata, but must not affect the format of serialized data.
Related
I have a problem where I want to search for data in an application's database managed by Core Data. The problem is, that the key I would be using to query the database may have several similar ways of being written. For example, I want to access same data element with name "tomato" with the key "tomato" or "tomatoes". All other data fields would be the same. Does Core Data offer any built-in functionality to create aliases for a key so that a single element can be accessed by multiple keys?
I tried adding duplicate elements that only different by the "name" attribute, but I do not want to do this for every entry as it would require my database to use at least twice as much space.
Examples in the InfluxDB documentation usually include a field named value. For instance, https://docs.influxdata.com/influxdb/v1.4/write_protocols/line_protocol_reference/#examples contains many example inserts that all include a value field, such as:
INSERT mymeas value=1.0
Is this use of value just a convention, or is there some special behaviour associated with the name value? I know that inserts without a value field are legal and that I can query for them with select queries just like rows with a value, but I don't know whether there's some special handling of values hidden under the surface that I'm not noticing.
The use of value as field name appears to just be a convention in the documentation. Neither the query language spec for identifiers or field keys mention anything about it (and value is not a keyword).
I am looking for a key value store database on iOS. It should be based on sqlite, so YapDatabase seems to be a good choice.
But I find YapDatabase only uses a single table, to quote "The main database table is named "database" ": CREATE TABLE "database2" ("rowid" INTEGER PRIMARY KEY, "collection" CHAR NOT NULL, "key" CHAR NOT NULL, "data" BLOB, "metadata" BLOB ). So I am concerned about storing different type objects into the same column.
For example, I plan to use YapDatabase for my chat app, storing each message into |collection|key|object|metadata|. Each message has a unique id, which will be used as the key, message content normally is nstring, which will be used as object, timestamp with some other data is used as metadata. Just like YapDatase author answered here.
Sometimes pictures will be sent. The images are small, normally around couple hundreds of kbs, I don't want to store them as files, I believe storing them as blob is appropriate.
But if I use YapDatabse they are stored in the same table as my normally text messages. Then how can I do some query like, said find all my text messages?
Is my concern valid (storing different type objects into the same column)? Do I need to store them in separated tables? If yes, how? If not, how do I find all my text message easily?
The whole point of a key/value store is that it uses only the keys to identify the values. So if you want to store messages and pictures in the same store, you must ensure that they have different keys.
If you want to store data in separate tables, use a database that actually has tables, like SQLite.
I'm currently using BigDecimal type in a Mongoid 3 app. There are multiple Documents and each has multiple BigDecimal fields. I'd like to migrate all the production data to type Money but keep the document field names the same. How should I do so without significant downtime?
One idea:
Create temporary fields in each Document with type Money
Convert data in existing fields into temporary field
Change original field type to Money
Copy data in temporary field to original field
Remove temporary field
Is there a better way?
There might be a group of records in a table where only two fields vary record by record, and rest fields remains same. This calls for a normalization by splitting by a table through a foreign key association. But, in Ruby-on-Rails, it would mean the creation of a model. So, is it still possible to lessen use of disk space?
May be, it is, because it would be reasonable that storing multiple values of one column in a record would require the column to be an array of any type. But declaring the field to be :array type results in an error. So, is there a way to work around it?
After generating a model, open the model's file. Insert one line for each field.
serialize :field_name
But ensure that the fields for which you are serializing, should be of type
:text
or
:string
If they aren't of such primitive data types, i.e. of another type like
:datetime
then it would return an error.
This step is not complete as a whole. You need to do one complementing step: de-serialize, because in the model-level storage, it is stored as a string starting with "---\n-", which is not suitable for array-type operations.
While reading data from the model, you need to perform the following step:
YAML.load(field_name)
where field_name refers to the field that was serialized.
The above step would return an array, on which you can perform normal array operations.