Tag Info

New answers tagged

1

QUERY #1 position the user 2 has if I sort by time and server = 1 SET @given_user = 2; SET @given_server = 1; SET @pos = 0; SELECT * FROM ( SELECT (@pos:=@pos+1) pos,User FROM playerstats WHERE server = @given_server ORDER BY time DESC ) A WHERE User = @given_user; QUERY #2 if I sort by the sum of the time of a user SET @pos = ...


1

When i did a systems analysis module in my years at university, i was doing my computer science degree. One thing our lecture told us all at the time was something we couldn't comprehend. "Strictly speaking, there is no wrong or right way to approach DBs" As computer scientists this is hard to swallow. lets look at your example: Ok, so you have ...


1

Note, that I assume C# (since this language is present in tags) and Entity Framework. Both approaches assumes, that entity types are inherited from abstract, non-persistent base entity type, which accumulates 75% of fields, so the code base discussion is not relevant. Pros of Table-Per-Hierarchy (all descendants are stored in single table): database ...


0

My opinion: Data duplication would be make complex and costly to updates and inserts. It is always application-specific and needs to be re-evaluated if the application changes. It can increase the size of tables.


1

If you don't always want to pass all parameters, create a function with parameter defaults. The basic, simple form would be an SQL function without dynamic SQL: CREATE OR REPLACE FUNCTION func( _a int = NULL , _b text = NULL , _c text = NULL) RETURNS TABLE(...) AS $func$ SELECT ... FROM ... WHERE (speed = $1 OR $1 IS NULL) AND ...


1

You can use Dynamic queries. Here is a page about it. Check out about 2/3rds of the way down after "Example 40-1. Quoting Values In Dynamic Queries". But like it states, you need to be VERY careful. Doing this type of SQL creation on the fly can be a huge hole for SQL injection. http://www.postgresql.org/docs/current/static/plpgsql-statements.html


0

Yes, there is at least one tool. It's not free, but there is a free trial : http://razorsql.com/features/hsqldb_database_conversion.html



Top 50 recent answers are included