How to properly use QGIS Symbology when operating with foreignkey-linked tables - qgis

I would like to use the Symbology-Categorized feature in table properties to organize the data representation by attributes. The column in my table contains only the foreign-key of a linked table where the actual value is stored.
Therefor I get only the foreign-key on the Symbology as a result.
As a workaround I use the Joins feature in table properties to create an additional column with the values from the linked table.
Is there a more elegant solution to solve this?
Thanks,
Anjo

Related

Postgres create table like exclude constraints but include indexes

I am trying to recreate a table's structure using following statement. However I would like to exclude constraints but include indexes from the original table.
CREATE TABLE users_audit (like users EXCLUDING CONSTRAINTS);
Above statement works as expected as it create a new table users_audit without constraints. However I am not sure if it is possible to copy indexes using INCLUDING INDEXES or even include everything except primary key constraint. Looking at the documentation it seems like I can only pass EXCLUDING | INCLUDING.
You can say
CREATE TABLE users_audit (like users EXCLUDING CONSTRAINTS INCLUDING INDEXES);
That will create all indexes, so it also will create the indexes that implement primary key and unique constraints. However, foreign key constraints won't be created.
There is no way to only create the indexes that do not belong to a constraint. For that, you could say INCLUDING INDEXES and afterwards drop all constraints.

Is it possible to use DBIx::Class on a database without relationships?

I'm new to DBIC. I've imported data into a database. It's not possible to create relationships between the tables because, apparently, not all the values in the child table's foreign key column have a corresponding value in the parent table.
So is it possible to still do joins between the tables? I've skimmed through the tutorial and documentation but found nothing that addresses this problem.
You can of course define relationships in your DBIC schema that don't have a matching constraint in the database.
If you use $schema->deploy it will automatically generate constraints for all foreign key columns.

Partitioning tables in PostgreSQL by a value stored in a different table

We are using a partitioning scheme that uses a date field in the table to determine the partition that should be used i.e. table foo with child foo_y2016m01.
This works for our simpler tables, but we are researching how to approach some of our more complex table relations to do the same style of partitioning, such as foo having a date field and bar storing the row id of the associated record in foo. The bar table does not have a date field of its own, but we still want to partition the table such that child tables would follow the same format (bar_y2016m01).
Is it possible to format the check constraint on bar such that it can use the date field from foo?
The answer is: Possibly.
You can use an expression in check constraint so you can write a function that will check the other table for you. However it will be only triggered during instert/update on the table so the data might loose integrity and you'll have to use a foreign key or add a trigger to table bar to keep foo correct.

EF many to many with junction entity database first

I have a junction table with and idenity primary key columns to realize a many to many relationship. Visual Studio automatically detects it as a many to many relationship and the junction table is not an entity.
How can i realize it that also this table is generated as an entity? I need this for breeze.js .
You just need to add additional columns (or properties) to that table (or model).
You said that your table has acolumn named ID and it's the primary key withe IsIdentity set to true. It must works, I'm using this approach...
There must be a problem or missing with your table definition. However, if all are OK, just add a nullable column in your table and update your model from database. The problem will go away.

EF db first and table without key

I am trying to use Entity Framework DB first to do quick prototyping of a reporting website for a huge db. The problem is one of the tables doesn't have a key. I got an 'Error 159: EntityType has no key defined'. If I add a key on the model designer, I got 'Error 3024: Must specify mapping for all key properties'. My question is whether there is a way to workaround this WITHOUT adding a key to the table. The table is not in our control.
Huge table which does not have a key? It would not be possible for you or for table owner to search for anything in this table without using full table scan. Also, it is basically impossible to use UPDATE by single row without having primary key.
You really have to either create synthetic key, or ask owner to do that. As a workaround, you might be able to find some existing column (or 2-3 columns) which is unique enough that it can be used as unique key. If it is unique but does not have actual index created, that would be still not good for performance - you should create such index.