1,575 reputation
618
bio website
location Ukraine
age
visits member for 2 years, 5 months
seen 14 hours ago

Sep
10
revised Constant values in columns
grammar
Sep
9
comment Database Design for lookup tables
So, again, fix the design (by allocating separate tables for different entities), and perhaps it will then be much easier for you to answer your original question yourself.
Sep
9
comment Database Design for lookup tables
Oh I see. Perhaps, "terrible" was a bit too harsh on my side and if the supporting team is happy with the present idea, good for you. It's just that I would hate to be on that team. :) My issue with this design is mainly about the referential integrity. Although the server would prohibit you from inserting a non-existent reference into any of the reference columns, it would allow you to insert one pointing to an entirely different thing than the column is supposed to hold, just as I said above and as the already mentioned example shows.
Sep
9
comment Database Design for lookup tables
@Polppan: Yes, separate tables for different things. The example by Ypercube shows that with your design you would be allowed to insert references into wrong columns. For instance, you would be able to insert a type into the category column and the other way round. How did you come up with this design in the first place? Is this an exercise, a working project, or something else?
Sep
9
comment Database Design for lookup tables
From your SQL Fiddle, it appears the answer to my question is "yes". That's a terrible design. You should have distinct tables for distinct entities. There should be a Category table, or perhaps even two: question_category, product_category, same for types and other things. You shouldn't mix all those in one table.
Sep
9
comment Database Design for lookup tables
Do you mean you have multiple foreign key columns and one and the same table & column that those FKs are referencing?
Aug
28
revised Constant values in columns
added 10 characters in body
Aug
28
answered Constant values in columns
Aug
28
revised Dynamic file name for file import
added relevant tags
Aug
28
suggested suggested edit on Dynamic file name for file import
Aug
27
comment How to relate two rows in the same table
Even if for some reason INSERT VALUES had worked differently from INSERT SELECT, there would still have been the option of INSERT INTO t SELECT 1, 5 UNION ALL SELECT 5, 1, which you say you are aware is considered a single statement.
Aug
21
revised EF Code First uses nvarchar(max) for all strings. Will this hurt query performance?
capitalisation
Aug
21
suggested suggested edit on EF Code First uses nvarchar(max) for all strings. Will this hurt query performance?
Aug
12
revised scramble the value of one column and unscramble it?
reformatted and reworded for possibly better clarity
Aug
12
comment scramble the value of one column and unscramble it?
On the other hand, why do you need to be able to restore original values?
Aug
12
suggested suggested edit on scramble the value of one column and unscramble it?
Aug
2
comment Select rows after a specific ID
@AdamHaines: In SQL Server 2012, it is possible to solve this without ROW_NUMBER. Please see my answer if you are interested.
Aug
2
revised Select rows after a specific ID
deleted 193 characters in body
Aug
2
answered Select rows after a specific ID
Aug
1
comment How to do aggregate functions in GROUP_CONCAT
Have you tried looking at the resulting query that you are executing eventually? I'm still not sure what the calculations must be but I suspect your last attempt is not bringing your the results you were hoping for. Just look at the query. It seems like you are trying to build a query without having a firm idea what it should look like. I suggest you first try writing a complete static query that does what you want. Basing off the static query, it will be easier for you to figure out how to construct it dynamically.