Storing multiple test answers in Access - forms

I'm fairly new to Access and have gotten stuck at a point despite hours of on-line research. In short, I'm trying to write a database that will store the answers that people give on several different tests. Some people take 1 test, some take 2, 3, etc. I need to store for each student what test(s) they took and what their answers were for each question. I feel like my current approach (make a separate field for each question on my MainRecord table along with a yes/no field for each test that can be taken) is cumbersome and leading to my ultimate problem: when I populate a continuous form with all of the test questions and an adjacent combo box to input their answer, I can't transcribe the combo box value back into my MainRecord. The data for the continuous form comes from a separate table (Test1) which has a field for question number and a lookup field that allows me to select the person's answer (i.e. A,B,C,D,E).
Is there a better way to construct my tables? If not, how can I get the combo box values on a continuous form into different fields on a table? Thanks, sorry if I sound like a moron.

You're going to need to look into a more generalized structure.
Here's a really basic structure that should work.
I can't help too much with all the continuous form stuff
Test
test_id
TestQuestion
test_id
question_id
question_order (used for sorting)
question_text
QuestionPossibleAnswers
question_id
possible_answer_value
possible_answer_prompt
Student
student_id
student_name
// etc...
StudentTest
test_id
student_id
date_taken
// whatever
(assuming a student can only take a test once)
StudentAnswers
student_id
question_id
student_answer (would be the possible_answer_value from "QuestionPossibleAnswers"
Anyway, when a student takes a test, your top form would be 'bound' to the 'StudentTest' table i guess. The continuous form would be based probably on StudentAnswer. The student_answer drop down would need to be bound to the current StudentAnswer.question_id's possible answers (through the query builder).
It's been years since i've done Access so i can't give step by step, I apologize, but the structure above is pretty sound (if not overly simple).

Related

Relational data with modifications/variants

Let's say a supermarket has one table with statistical revenue data by business day. In a second table they want to try out different variations of these data, f.e. less bakery revenue at 1st January, one more public holiday or maybe opening on sundays.
I do not want to duplicate the whole revenue data of a year or more for just a few variations. Additionally it should be easily possible to show the diff between the base table and one alternative scenario.
To make it a little more clear, I created a demo case at SQLFiddle. SUPERMARKET_DAYS is the table with the base revenue data. ALTERNATIVES are the variations/alternatives or scenarios (however you want to name it) and ALTERNATIVE_DAYS is a table with a similar structure as the first one and holds the concrete changes.
Example at SQLFiddle
SUPERMARKET_DAYS
(
ID,
DAY,
NUM_CUSTOMERS,
NUM_VISITORS,
REVENUE_BAKERY,
REVENUE_BEVERAGE,
REVENUE_CANNED,
REVENUE_DAIRY,
REVENUE_DRY,
REVENUE_FROZEN,
REVENUE_MEAT,
REVENUE_CLEAN,
REVENUE_PERSONAL_CARE,
REVENUE_PAPER,
REVENUE_OTHER
)
ALTERNATIVES
(
ID,
TITLE
)
ALTERNATIVE_DAYS
(
ID,
DAY,
NUM_CUSTOMERS,
NUM_VISITORS,
REVENUE_BAKERY,
REVENUE_BEVERAGE,
REVENUE_CANNED,
REVENUE_DAIRY,
REVENUE_DRY,
REVENUE_FROZEN,
REVENUE_MEAT,
REVENUE_CLEAN,
REVENUE_PERSONAL_CARE,
REVENUE_PAPER,
REVENUE_OTHER
)
I do not even know, if this schema design makes any sense but it illustrates the problem.
How would you store this kind of data?
I thought about something like a versioning table but this does not really solve my problem.
I could merge both tables inside of my java code.
Is there something like the MERGE functionality for views?
I would really be grateful for every kind of idea or the correct keyword for my own investigations. This problem should already exist but I didn't find much to solve it, so I maybe did not search with the correct terms.
Thank you everybody!

Automating a data feed into a PostgreSQL table when the number of columns could change and there are duplicate names

My company uses a third-party vendor to get all of our NPS information. I'm trying to set up a data feed from this vendor into our data warehouse, which runs PostgreSQL.
The feed is in the form of 2 tab-separated text files: "question mapping" and the responses. The question map is one row per question, with columns for question id, question text, question label question type, etc - straightforward. The responses are one row per survey response, with a column for each question and stuff like user id, etc. Here are the 2 biggest problems:
The survey questions sometimes use the same question ID for different questions, resulting in multiple columns in the response data having the same name but not being the same question.
The number of questions could change, resulting in a different number of columns in the data.
Both of these things make it a real headache to automate a data feed into a single table.
I'm afraid I don't quite know how to phrase my real question other than, "Does anyone have any ideas how I can accomplish this?" If I think of something better than that, I'll come and update this, so for now:
Does anyone have any ideas at all about how I can efficiently set up my automated data feed without having to always drop and recreate everything?
If your data is a mess and doesn't really have well defined columns you can use the entity attribute value pattern, where you turn each fact into a set of rows with 4 columns - a unique row id, the same entity id for each row extracted from the map, an attribute column (where you put what would be the name of the column) you get from the key of the map, and a value column where you put the value from the map. It's not that neat but you can still query it and you won't have to drop it when you receive a map with a new column.

Adding a 'Heading 1' to a Word 2010/13 Doc in Alphabetical Order

I'm operating in Word 2013 and 2010, so I can use code that works in either. I'm trying to create a word document to keep track of my recipes. At its most basic I want to have a TOC that updates based on headings. I also want it to have any category I want (eg: Appetizers, Drinks, Entrée, etc...) ordered alphabetically. Under each category I have tables. Each recipe gets a table that has it's name, directions, notes, tags, and potentially a picture. The second cell has another two column table inside of it that contains the quantity and name of each ingredient necessary for the recipe.
I have all of that so far and I'd like to automate adding new categories and recipes. Currently, I have to find the category, then scroll down to find where the name goes alphabetically and insert a quick table I made. I then fill in the info.
I'd like to be able to search the document for each category name, then insert the new category wherever it belongs, with a space before and after it. I found that my tables give me trouble if I don't have a space between everything. It tries to pull anything it's touching into the table and merge them.
I wanted to give the backstory, so you'd know where I was going to go eventually and could provide help that fits better with what I need. After I can add a new category, I plan to use vba to organize each table alphabetically by the name in the first cell of each table. It will also help when I start adding sorts to it. Eventually, I'd like to be able to sort it to say, only display recipes from a certain person, or display my frequently used recipes. I'd then have it either hide all the others or create a new doc with just these. So thanks for the help. Below I'll post the code I most recently tried. I tried a few other variations of this same code and keep getting an 'expected end of statement. I've gotten other errors when trying other variations of it, but this is the best I can come up with on my own.
Private Sub UserForm_Initialize()
For Each cat In ActiveDocument.Styles = "Heading 1"
lstCat.AddItem (cat)
Next
End Sub
I have a form called frmAddCategory I'm using as a test. I was going to have a listbox lstCat to show every category with the style heading 1. I have a textbox called txtAdd to type new ones and a cmdAdd button to add it to the form.
Edit: I've been playing around with my macro recorder after finding out about outline view mode. I set it to show only 'heading 1' level and selected the ones I wanted, not selecting the appendix or reference. Then I went to the home tab and sorted paragraph by ascending alphabetical order. I got some code I believe I can use to get it to run in VBA. However, it's not a complete fix as I don't want to select the last two with heading 1. It also works if I manually select the tables under each heading 1, but I can't set the spacing before and after. I'd like each heading and the tables under them to have a space or two between each for looks and editing purposes.
Also, if someone is going to give my question a negative rating, then please post a comment explaining. As far as I can tell from the faq about the forum and the other questions I've seen, it is a well posed question. A clear title, a good explanation of the problem, code examples, research. So if I am doing something wrong, please inform me, so that I can correct it.
first thanks for your bit about macro recorder and outline mode, I have been trying for long time to fill a list box with selection.text between two HeadingLevel(1) headings.
now to yours, sorry I can't think of way to do in word. BUT it would be real easy in Access. one table of categories like called tblCategories another for recipes tblRecipes. To make real easy, when the use autoID on ALL tables. But to avoid LOTS of headaches for tblRecipes rename its autoID to RecipesID same for other tables. in table of recipes you can use a memo field to hold large amount of data. the spot for text in Heading would be put in one field of the tblRecipes. once you have tables looking to have a field for each item you want to track. hit save, then use wizard to create a form based on table. repeat for all tables you want to have it real easy to put info into any table.
1.reportTOC based on query of Every Heading you want, can preview or print as want. reportByCategory and so on reports are sorted a to z unless you want to sort by Owner, then recipe all auto sorted a - z.
report wizard to get hard copy. if you want to sort real easy, built in. also if want to be able to pick all recipes for a holiday real easy, one table tblHolidays. one tblHolidayRecipes fields autoId (not used by you anywhere but needed), fldRecipesId (holds RecipesId) , fldHolidayId (holds HolidayId). the wizard will show how to get only what you want. in access 2013 you can include pix of food or.

Creating long forms in FileMaker Pro

I am creating long forms in FileMaker Pro with many unique questions in each form.
Each unique question is comprised of: a radio button, two fields of support data, 4 container fields, and a field for comments. There is also a map feature that collects the device location when using an iPad.
Because each question is unique, I have been creating up to 8 fields for each question. The forms I am creating contain up to 40 questions.
Example fields:
Question1
Question1_Comments
Question1_Value1
Question1_Value2
Question1_Image[1], Question1_Image[2], Question1_Image[3], Question1_Image[4]
Is there is a simpler way of approaching this?
Yes. I can offer some general suggestions, but it sounds like you need to normalize your data. Whenever you start creating fields of the form Field1, Field2, etc., that's a hint that you should probably create a separate table. In your case it sounds like you need at least three tables:
Forms
Questions
Files
This is going from the information you've provided that each form has many questions and each question has many files (container fields). Assuming that your form table already has a primary key field (a field that is unique for every record, often an auto-enter serial number), the Questions table would have the following fields:
id (primary key)
form_id
question
comments
value1
value2
Then the Files table would have two fields:
id
question_id
file
Then you'd create a relationship from Forms to Questions with Forms::id=Questions::form_id and from Questions to Files with Questions::id=Files::question_id. If both of the value fields will always have data, I'd leave them in the Questions table, but if one of them could be blank, or if you think you may someday want more than two, I'd break that into it's own table as well.
Check the FileMaker documentation for more information on creating relationships.

FullText Index - Searching values from another table

Is it possible, in SQL Server 2008, using the full text index syntax, to run a query such as this one?
SELECT *
FROM TABLE_TO_SEARCH S,
TABLE_WITH_STRINGS_TO_SEARCH SS
WHERE
CONTAINS(S.WHOLE_NAME,SS.FIRST_NAME)
OR CONTAINS(S.WHOLE_NAME,SS.LAST_NAME)
I need to search for the FIRST_NAME in table TABLE_TO_SEARCH, column WHOLE_NAME that has an full text index on it. It doesn't seem to be a valid query though... Is there any workaround to it by using the full text index search?
LATER EDIT:
Here is the business case: each night I am downloading from several websites information about "blacklisted" individuals and insert it into a table in this format: WholeName, LastName, FirstName, MiddleName. But the data is chaotic as WholeName does not necessarily contain either the last, first or middle name or the WholeName is null while the other 3 fields have values, or every of these 4 fields is null and so on. Also, the data may repeat itself as one blacklisted individual may come from 2+ of these websites. What I need to do is to compare this data, as chaotic as it is, against our customer data based on our customer's First and Last name and give it a matching score (rank) against the files we download from these websites.
First I tried with charindex or like operators but I couldn't create a scoring algorithm based on this and also it took 6 hours to compare just our customer's first and last name with only the WholeName column from the TABLE_TO_SEARCH table. I thought that perhaps implementing the full_text index it would get easier and faster but ... apparently I was wrong.
Has anyone dealt with a task like this? And if so, what was the best approach?
After skimming http://technet.microsoft.com/en-us/library/ms187787.aspx and http://technet.microsoft.com/en-us/library/ms142571.aspx I don't think it is possible to do your search in this way. Not only that, but it seems this type of index wouldn't work well with names anyway.
If you care about checking one name then all you have to do is set those values to variables. This method would allow you to use the full-text index.
Otherwise, I would suggest splitting the WHOLE_NAME column (if there is a space or unique character between the first and last name) and comparing each part to those other columns. If you are working with a huge data set, you may want to experiment with doing this at a temp table level and creating an index.
Good luck!