Been stuck with this for hours.
I have 5 forms that has (multiple textbox, checkboxes etc) with data related with each other. Now I want to save all those data (from form1 to 5) to my database with just 1 button Save in form5.
ps. I don't want to separate insert queries or make tables to all forms that will mess up the ID's. I already have 5 tables Applicant_name, Address, Permit_table, Licence_table
or if not possible How to Insert those Data with all table ID's still the same ex. 1 | 1 | 1 | 1 | 1
It is interesting solution. I think you need to change your solution, especially your database design. But I can give advices to you;
You can solve this problem with Interface or create a base class.
Your 5 forms inherited from this created base class and set base
class attributes.
The other solution is create an (arraylist,list,array etc..) for
each form and fill them with information and pass these collections
to database related class (which button you want to click)
Related
I'm trying to filter data with parameter based on user_id with tableau. There's 3 columns: user_id, content_team, seconds. Some of the sample datas are:
user_id | content_team | seconds
1 | AR | 2030
2 | VR | 1020
1 | AR | 1500
2 | VR | 3000
3 | HOLO | 2230
Right now I have the sum(seconds) of the content_team for all the users combine
How can I create a parameter in which it takes a user_id and display the sum(seconds) of the content_team for that particular user only? Thanks
The use case for using parameters in filters is usually that you have more than one data source that are not joined but do contain a common field. There is little benefit to using parameters when there is only one data source as simple filters work better.
But when you want common filters across multiple sources, can't join them into a common source, but don't want to lose some of the functionality in each sheet, then parameters work.
Say you have multiple data sources at different levels of detail but containing the same filterable field say user_id then you can create a parameter built on that field (and recent versions of Tableau can automatically update the content of the parameter on loading the workbook). The way to filter across the sources is to create a parameter called, say, user_id_parameter which is updated when the workbook is opened and then to filter each individual sheet using a calculation eg [user_id]=user_id_parameter where the user_id in each case is from the relevant data source. then, when the parameter is changed, each separate data source will be filtered to show only the data with that user_id even across multiple otherwise unlinked data sources.
This functionality (now that parameters can update on load) vastly simplifies the process of creating "universal" filters that work across multiple data sources in a workbook.
If you only have one data source, the technique still works but has little to no advantage over just filtering on the relevant field (and, don't forget, you can set a filter to apply to all sheets or a range of specified sheets).
I am using an external program that writes onto Access. This program collects data from an electronic form and writes all the data from the submitted form onto my Access database. However, the issue that has arisen and caused a lot of issues and slowed down our database, is that when it writes to my database, the data is not normalized.
The form looks something like this
Name: John Doe
DOb: April 1 1950
SIN: 123456789
Marital Status: Married
Phone: 123456789
Email: john#email.com
Then it writes everything on the form as one record using the Question as the field name and the entered data as the data. Something like this:
Name | DOB | SIN | Marital_Status | Phone | Email
John Doe| April 11 1950| 123456789| Married | 123456789| john#email.com
See this isn't much of an issue with the example form here, however, we have forms with about 100 questions which which we end up with a table with fields like:
Name|Date|Weather|Question1|Question2|Question3|Question4|...|Question100
.... and so forth.
As a noob, what I have done thus far was using the union sql query to manipulate the data so that it reads:
Name|Date|Weather|Question1
Name|Date|Weather|Question2
Name|Date|Weather|Question3
Name|Date|Weather|QuestionN
I have been able to get by with this but it is seriously slowing down my database and now I am having other issues.
How can I normalize this data when the external program writes data like this? I don't get to manipulate how the program writes to my Access Database.
Access 2010 has a feature called event-driven data macros, which are similar to triggers in other database systems. I don't personally have any experience using them, but it looks like you should be able to create an After Insert macro that will run when a new row is inserted. Within that macro you could split your questions up and insert them into a more normalized table (which you would then use to report off of).
You're doing it correctly, a union query is indeed the correct way to normalize a denormalized table. However, consider storing it normalized in addition to denormalized, so you can actually work with the data without having Access executing 100 queries every time you want to access your data. And consider splitting Name|Date|Weather to a different table, since you are repeating them 100 times per question.
You can store the union query result in a table by simply doing SELECT * INTO MyTable From UnionQuery. Combine the import from the other program with this query in a macro.
Obviously, this is not ideal. The ideal fix would be to manipulate the external program to not denormalize the data in the first place
I have a very large amount of data that would most naturally be represented as a tree:
Category 1
Sub-category 1
data point 1
attribute 1
Sub-cateogry 2
data point 1
attribute 1
attribute 2
data point 2
Category 2
Sub-category 1
Sub-category 1
data point 1
Sub-category 2
data point 1
data point 2
Sub-category 2
data point 1
data point 2
data point 3
...
The individual data points have text and numerical attributes, bit it doesn't really suited for representation as a set of related tables. I would like to be able to perform SQL-like queries, but I would also like to be able to browse through the data in a way that makes the tree structure of the data obvious, like with a file manager.
There's probably some class of application that is ideal for such a thing, but it isn't occurring to me at the moment. Some kind of combination of a database and a tree viewer control? Anyone know what it is I'm looking for? As always, I'm terrified of asking a question in the wrong forum, but I see some related questions here at stackoverflow, so hopefully it's OK. Thanks!
You could make a table like this
id
name
parent_id
This structure would allow for nested categories
You could then make a table that relates category and data points.
The java.swing packages contain several table and tree solutions such as the JTable and JTree classes. JTree can be easily constructed to produce the tree structure you are looking for (looks like a file directory.)
The JTable class can be used to create sortable and searchable tables, although you would have to borrow or write your own sort & search methods.
Although these are from Java, other languages offer similar structures that may serve your needs without using a database. That being said, "mySQL" is a very easy to use database and you can download the community DB package for free.
Ok, so I need some SQL 101 assistance. I am building a new table in SQL that will be used in a VPN connection to an outside source. I have built a view inside of SQL that contains all the information I need from the main database for this new table. I now need to push the data into the table. The problem is that the data is constantly changing and I am not really sure what my easiest way to do this is. I need to be able to copy the data from the view to the table initially but after that I need to be able to update already existing records with new information and insert new records into the table that don't already exist.
Now, the reason I am not just using the view to deal with the data needed through the VPN is because the outside source that will be using the data needs to be able to push back some values that don't exist anywhere in my table and save them to the unique records they are associated with. When I do the update, I need to leave those values that are pushed back alone and just update the values that already exist in my database.
I hope this makes sense as I need some guidance on how to do this as I have not done this before.
The table for this looks like this:
ID Name Address Email X Y Z<br>
123456 John Smith 123 Any St john#d.com 123 12 1125
X Y & Z are the fields that will be filled from an outside source which will be tied to the ID number of the record from the web service.
Thanks for the assistance
I've got a table in my database storing items:
Items
-------
ItemID
Name
...
Etc
and a separate table storing the PK of two different items from the first table. I want to be able to list the one item, and then any number of related items. I've tried searching for examples but haven't found much surprisingly...
RelatedItems
------------
ItemID
RelatedItemID
If I have four products, whose IDs are 1, 2, 3 and 4... and 1 is related to 2 and 3 I might have data that looks like this:
ItemID RelatedItemID
1 2
1 3
4 1
I am then modeling them in the Entity Framework Designer, and the designer automatically adds an association from the Items table to itself (many to many). The designer also adds two navigation properties, if I use the first property on Item #1 I get all items where Item #1 is in the first column, and if I use the second property I get all the items where Item #1 is in the second column.
I however just want to have one navigation property where I can say Items.RelatedItems and it returns all the items that the above two properties would when combined. I know I can join the two results after the fact but I can't help to think I'm doing something wrong and there is a better way.
Hopefully this is all clear enough.
It sounds like SQL schemas just aren't very good at modeling the concept you're looking for. The schema you've chosen would work well if you want to establish a directional relationship (item A is related to item B, but item B may or may not be related to item A). If you were looking for a grouping-style relationship (Items A and B are in the same group), I can think of a different approach you'd use. But I can't think of a good way to model an inherently bi-directional relationship using a traditional relational database.
Some workarounds might be to use a View that joins the two results, or to use triggers to make sure that every mapping from A to B has a corresponding mapping from B to A, so that both of the properties always return the same objects.
If you have an instance of an Item, call it item, then the following will give you the related items...
item.RelatedItems.Select(ri => ri.Item);
Your RelatedItems property on item (ie the first navigation property you mentioned) will be a collection of RelatedItem objects, each of which has two navigation properties of its own, one of which will be named Item and will be a link to the related item.
Note that this is air code, as I'm not in front of anything I can test this on right now, but I think this will do what you want.
If you want to make it simpler, you can write an extension method to wrap up the Select(), something like this...
public static IEnumerable<Item> RelItems(this Item item) {
return item.RelatedItems.Select(ri => ri.Item);
}
Then you could just do...
item.RelItems();
Note that I couldn't name the extension method RelatedItems, as that would clash with the navigation property that EF would have created for the second table. That's perhaps not a good name for that tables, as it's not the actual items, rather the IDs of the items. Either way, the above code should work.