Are there examples of a contingency table dataset in R that contains missing values? I'm not willing to create one, I'm looking for an already existant dataset. Or if you do know where I could find some and import it, it would be more than welcome!
Thank you for your help!!
Related
I'm trying to join two tables together through a relationship but am having trouble.
My data is of a Building (type text) , which has Floors and Rooms which can both be a mix of text and number names (type any).
In order to create a relationship based on the Room column, I attempted to create a unqiue values table by referencing the Room_Mapping table, removing all by columns apart from Room, and removing duplicates.
However, when I try to join the two tables together based on the Room column, I keep getting the following message.
I have a feeling that this error is coming because the data type is a mix of text and numbers that it is getting confused because when I go to look at the data in Data view, I can see that the data for Phase and Room fields have been converted to Text type.
Please can any one help? I have attached a link to the workbook and data in the link below.
Room_Mapping Data and PBI Workbook
Many thanks in advance.
The Room1/ROOM1 Room2/ROOM2 are the cause of your problem. You can solve this by adding one extra step to your Query.
You do this by right-clicking the Room column and choose Transform > Capitalize Each Word.
The problem is that you have 4 very similar cells:
Room1
ROOM1
Room2
ROOM2
in original table and them are duplicated yet in the Room_UniqueValues Table.
Try to replace this values like this in the Room_UniqueValues Table:
And null by "null" in the original table, for example:
Tell me if this are ok please!
Might be a silly question to ask but what data type should I setup a column so I can enter multiple values?
Example: I have two tables, one called Application_users and the other Products.
Application_Users has an id column.
What I want is to have a column in Products which is called Application_Users_id and I enter 1,2,3,4
The idea is if an Application_User_id is say 3, they would only see products were the Products.Application_Users_ID contains a 3.
So what data type do I use so I can enter values such as 1,2,3,4 in a column?
I have tried NVARCHAR and INTEGER but neither work (NVARCHAR works but won't let me amend it e.g. add numbers).
Let me know what everyone thinks is the best approach here please.
Thanks
John
It might be a silly question but you would be surprised how many developers makes the very same mistake. It's so often that I have a ready-to-paste comment to address it:
Read Is storing a delimited list in a database column really that bad?, where you will see a lot of reasons why the answer to this question is Absolutely yes!
And if you actually go and read this link, you'll see that it's so wrong and so frequently used that Bill Karwin addressed it in the first chapter of his book - SQL Antipatterns: Avoiding the Pitfalls of Database Programming.
Having said that, SQL Server Does support XML columns, in which you can store multiple values, but that is not the case when you want to use them. XML columns are good for storing stuff like property bags, where you can't tell in advance the data types you'll have to deal with, for example.
tl;dr; - So what should you do?
What you want to do is probably a many to many relationship between Application_users and Products.
The way to create a many to many relationship is to add another table that will be the "bridge" between the two tables - let's call it Application_users_to_products.
This table will have only two columns - application_user_id and product_id, each of them is a foreign key to the respective table, and the combination of both columns is the primary key of the bridge table.
It might be a stupid question, but I couldn't find anything relevant on the internet regarding the next thing.
I have the following matrix in an Excel file:
ClientCode | ClientDescription | THBCK | THHSM | THOEP
Cl0001 MyClient YES YES NO
*Where THBCK etc represents ItemCode.
The next steps are: I import the file in a temp table using the import wizard and I would like to create other custom tables based on that temp table in order to manipulate the information much better.
So, I create a table in which I store information about client code and description (I can select the columns header) which works fine. But when I am trying to create the second custom table I get stuck... the wizard is treating THCBK (which for me means the ItemCode) as being column header which is right taking into consideration the wizard purpose, but it does not helping me.
Is there any way I should do in order to create the 2nd custom table based on the ItemCode but with a different column header description for each?
Thank you
cross apply helped me in this situation. I have used cross apply and not UNPIVOT because the UNPIVOT does not include NULL values.
I'm hoping someone can help me because, despite finding numerous other questions like this one, I can't seem to find an answer specific to this problem?
I have two tables, TblReportsStore and TblReportsStoreComments as follows:
I want to add a new record to TblReportsStore, and then pass the TblReportsStoreID of that record to the intReportID column of a new record in TblReportsStoreComments. If it helps at all, the data is coming from a spreadsheet where the only changing data is the txtSchoolID and the txtComment.
One way is to use output. This assumes that it is an Identity column. Otherwise you could use NEWID() with the values:
INSERT INTO TblReportsStore(...)
OUTPUT INSERTED.TblReportsStoreID,txtComment
INTO TblReportsStoreComments(intReportID,txtComment)
VALUES ...
I need to make a scheme for an database. My problem is, that I have multiple questions they belong to one exam. That means: One Exam has multiple Questions. I don't know how I can solve that. I have try to fix it with an table between "tabQuestions" and "tabTest" but I doesn't seems to be the correct approach.
I have the following tables:
tabTest: ID, Name, FK_Categorie, FK_Questions
tabQuestions: ID, Question, FK_Answer
tabAnswers: ID, Answer, FK_Solution
tabSolution: ID, Solution
Thank you very much for the help!
Luca
You don't need the FK_Question field in your tabTest. What you need is a FK_Test field in your tabQuestion table where you store the id of the test the question belongs to.
...if I understood you right...?
And if I understood you right, then you should use the same for the rest of the schema too. This means you need a reference in your solutions table where you store the answer the solution belongs to etc.
You need to create two tables for this. One for exam (test) and one for questions.
The table exam (test) should have:
test_id, test_name
The table question should have:
test_id (references test_id from test table),
question_id ,
question_text.
Now you can have a 1:n relationship where one test has many questions.
But do not, I repeat: do not, store multiple questions in one row. That violates every possible good database design. Your selects, updates and inserts will be near impossible to write.
This website seems to have very good pointers for you.