I have a form that is bound to a crosstab query. The relations the query is based on are:
Client Person Address
|--------| |----------| |----------|
|ID | |--1|ID |1--| |ID |
|IdPerson|----| |... | |---|IdPerson |
|--------| |----------| |----------|
Now, the query is 'not updateable', so I set the 'Recordset Type' of the form to 'Dynaset (Inconsistent Updates)', so that the form allows me to input data in the bound fields.
When I try to save (go to next record etc.) the form, it says "You need to fill 'IdPerson' field". But how can I know the value for it? I can't. So I wrote a handler for 'BeforeUpdate' event, where I would like to predict the ID, the new row in Person would get and set the IdPerson for Client and Address fields. I cannot find a way to do this, meaning where is the row that is about to be inserted stored and how do I modify it? And that's my question.
Thanks in advance.
PS: I'm not sure that if I provide the values for IdPerson, Access will actually save anything, as there are constraints on the relations. It will depend on the order it saves the tables. If you know better approach (preferably without subforms), please share.
Related
I have two entities in my dynamo table: User and Order.
Each user has 0..* orders and each order has exactly one associated user. Every order also has a orderDate attribute, that describes when the order was placed.
My current table is structured as follows to make retrieving all orders for a specific user efficient:
+--------------+----------------+--------------------------------------+
| PK | SK | Attributes |
+--------------+----------------+-------------+-----------+------------+
| | | name | firstName | birthDate |
+--------------+----------------+-------------+-----------+------------+
| USER#userid1 | META#userid1 | Foo | Bar | 2000-10-10 |
+--------------+----------------+-------------+-----------+------------+
| | | orderDate | | |
+--------------+----------------+-------------+-----------+------------+
| USER#userid1 | ORDER#orderid1 | 2020-05-10 | | |
+--------------+----------------+-------------+-----------+------------+
I now have a second access pattern where I want to query all orders (regardless of user) that were placed on a specific day (e.g. 2020-05-10) along with the the user(s) that placed them.
I'm struggling to handle this access pattern in my table design. Neither GSIs nor different primary keys seem to work here, because I either have to duplicate every user item for each day or I can't query the orders together with the user.
Is there an elegant solution to my problem?
This is a perfect use case for a secondary index. Here's one way to do it:
You could create a secondary index (GSI1) on the Order item with a Partition Key (GSI1PK) of ORDERS#<orderDate> and a Sort Key (GSI1SK) of USER#<user_id>. It would look something like this:
The logical view of your GSI1 would look like this:
GSI1 would now support a query of all orders placed on a specific day.
Keep in mind that denormalizing your data model (e.g. repeating user info in the Order item) is a common pattern utilized in DynamoDB data modeling. Remember, space is cheap! More importantly, you are pre-joining your data to support your applications access patterns. In this instance, I'd add whatever User metadata you need to the Order item so it gets projected into the index.
Make sense?
Unfortunately, I can't seem to figure out a way to elegantly solve your problem.
You need to either duplicate the user info and store in the order record or use a second getItem to query the user-specific info.
If anyone has better solutions, please let me know.
We have a people table, each person has a gender defined by a gender_id to a genders table,
| people |
|-----------|
| id |
| name |
| gender_id |
| genders |
|---------|
| id |
| name |
Now, we want to allow people to create forms by themselves using a nice form builder. One of the elements we want to add is a select list with user defined options,
| lists |
|-------|
| id |
| name |
| list_options |
|--------------|
| id |
| list_id |
| label |
| value |
However, they can't use the genders as a dropdown list because it's in a different table. They could create a new list with the same options as genders but this isn't very nice and if a new gender is added they'd need to add it in multiple places.
So we want to move the gender options into a list that the user can edit at will and will be reflected when a new person is created too.
What's the best way to move the genders into a list and list_options while still having a gender_id (or similar) column in the people table? Thoughts I've had so far include;
Create a 'magic' list with a known id and always assume that this contains the gender options.
Not a great fan of this because it sounds like using 'magic' numbers. The code will need some kind of 'map' between system level select boxes and what they mean
Instead of having a 'magic' list, move it out into an option that the user can choose so they have a choice which list contains the genders.
This isn't really much different, but the ID wouldn't be hardcoded. It would require more work looking through DB tables though
Have some kind of column(s) on the lists table that would mark it as pulling its options from another table.
Would likely require a lot more (and more complex) code to make this work.
Some kind of polymorphic table that I'm not sure how would work but I've just thought about and wanted to write down before I forget.
No idea how this would work because I've only just had the idea
The easiest solution would change your list_options table to a view. If you have multiple tables you need have a list drop down for to pull from this table, just UNION result sets together.
SELECT
(your list id here) -- make this a part primary key
id, -- and this a part primary key
Name,
FROM dbo.Genders
UNION
SELECT
(your list id here) -- make this a part primary key
id, -- and this a part primary key
Name,
FROM dbo.SomeOtherTable
This way it's automatically updated anytime the data changes. Now you are going to want to test this, as if this gets big it might get slow, you can get around this by only pulling all this information once in your application (or say cache it for 30 minutes and then refresh just in case).
Your second option is to create a table list_options and then create a procedure (etc.) which goes through all the other lookup tables and pulls the information to compile it. This will be faster for application performance, but it will require you to keep it all in sync. The easiest way to handle this one is to create a series of triggers which will rebuild portions (or the entire) list_options table when something in the look up tables is changed. In this one, I would suggest moving away from creating a automatically generated primary key and move to a composite key, like I mentioned with the views. Since this is going to be rebuilt, the id will change, so it's best to not having anything think that value is at all stable. With the composite (list_id,lookup_Id) it should always be the same no matter how many times that row is inserted into the table.
I currently have a form in InfoPath with a repeating table eg:
Author | Location | Book (repeating table)
What I am trying to achieve is:
Author | Location | Book (Title1),Book (Title2),Book (Title3) etc
I understand that this is a short explanation - so feel free to request further info, if needed.
The Book field writes the first entry, ignoring book2, book3 etc. I need the field to work like an array field1(book1),field2(Book2), etc. Everytime the text field is repeated a new field should be created, saving the value.
It sounds like you just need a nested repeating table. Here's an example with the nested table having just one column (you can delete the header row).
can anyone explain in very simple words what the <group> tag stands for. I already read this: enter link description here
But I can't get it, I played with reports over three hours but can't get any results.
__
I have a csv datasource looking like that:
Name | Value
-------------
Ab | 123
Ba | wow
Cb | got
De | it
For instance I would like to get only the entry in the value column where the entry in the Name column is "Cb" (would be "got").
Hence, I created a group with: following expression: $F{Name}.compareToIgnoreCase("Cb")
Unfortunately I always get the entire column although I only want one entry.
Do I use the group tag in the right way? Maybe I have misunderstood the intended purpose of this tag.
Any help would be appreciated.
2014-March-22:
I made a simple example PastBin:minimalcode-jrxml-file using following csv file as datasource:
Name;Tom
Birthday;01-May-1980
Country;Germany
sex;male
Here is a screenshot of the design view (ireports 5.5.0):
And here is what I get when I click on preview (in ireports), unfortunately this is not what i want:
Maybe anyone can help.
Thanks
The purpose of this tag is to "group/unite data based on a specific column value. Let's take for example the classic HR schema. Every Employee is linked with a specific Department. While getting all the employees inside a report, you can "divide" them in groups based on the department on which they are connected (i.e: by creating a group with for the employee.department_id attribute). A simple usage might be creating different tables with employees records for every department. Basically, is the same function as the Group clause in SQL (only that Jasper is aware of these groups and allows you to customize them).
In your case, i'm not quite sure that the expression used is creating a jasper-group. Anyway, what you're trying to do (i mean, getting only that record) can be easily accomplished by a "WHERE" clause inside the report query: WHERE name='Cb'
You don't need group use filter expression:
<filterExpression><![CDATA[$F{Name}.equalsIgnoreCase("Cb")]]></filterExpression>
Forgive my ignorance, but I'm wondering if there is a way to specify metadata for a table in PostgreSQL that I don't want it to be as a field in that table. For instance, if I want to add a Description field for that table, creation Time, etc...
I know I can do this using extra tables, but I'd prefer having not to do this, to be honest. I've digged in the official PostgreSQL docs, but there's nothing there besides looking in information_schema.tables, where I guess I'm not allowed to modify anything.
Any clues? Otherwise, I guess I'll have to create a few more tables to handle this.
Thanks!
There's the comment field:
COMMENT ON TABLE my_table IS 'Yup, it's a table';
In current versions the comment field is limited to a single text string. There's been discussion of allowing composite types or records, but AFAIK no agreement on any workable design.
You can shove JSON into the comments if you want. It's a bit dirty, since it'll show up as the Description column in \d+ output in psql, etc, but it'll work.
craig=> COMMENT ON TABLE test IS 'Some table';
COMMENT
craig=> \d+
List of relations
Schema | Name | Type | Owner | Size | Description
--------+----------------------+----------+-------+------------+-------------
public | test | table | craig | 8192 bytes | Some table
You can get the comment from SQL with:
SELECT pg_catalog.obj_description('test'::regclass, 'pg_class');
Comments can also be added on other objects, like columns, data types, functions, etc.
If that doesn't fit your needs you're pretty much stuck with a side table for metadata.
People regularly request table metadata like creation time, etc, but nobody tends to step up with a workable plan for an implementation and the time and enthusiasm to carry it through to the finish. In any case the most common request is "last modified time", which is pretty horrible from a performance point of view and difficult to get right in the face of multi-version concurrency control, transaction isolation rules, etc.