cardinality

How to determine programmatically MySQL relationship type (1:1, 1:n, n:m) between tables?

穿精又带淫゛_ 提交于 2021-02-08 03:57:14
问题 I'm trying to query a MySQL server to determine information about a database in order to scaffold some code. I've been quite successful using Java JDBC and INFORMATION_SCHEMA table for this but the problem is that I need to determine if a table relation is OneToOne , OneToMany or ManyToMany . I can't find a good way to achieve this and I would love if someone could help me a bit and if its possible with a solution that is not MySQL specific and solid so it could help others. I found this

How to count a number of unique documents by a nested field in Elasticsearch?

丶灬走出姿态 提交于 2020-04-16 02:28:30
问题 I'm trying to count documents with unique nested field value (and next, the documents itself also). Looks like getting the unique documents works. But when I'm trying to execute a request for count , I'm getting an error as follows: Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://localhost:9200], URI [/package/_count?ignore_throttled=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true], status line [HTTP/1.1 400 Bad Request] {"error":{

Index on Mysql column has lower cardinality than count distinct?

允我心安 提交于 2020-01-07 05:38:06
问题 I have a varchar(50) field named token. When I do count(distinct token) from table I get ~ 400k. However, if I do create index idx on table (token) The cardinality is only 200. What could be going on here? Shouldn't cardinality be the same as the number of distinct tokens? 回答1: The cardinality is an estimate of the number of unique values in the index. According to the documentation: Cardinality is counted based on statistics stored as integers, so the value is not necessarily exact even for

Cardinality violation when using a subquery that returns two values

不问归期 提交于 2020-01-06 02:44:07
问题 I have create a sql query that the sketch is like this select * from A where A.id in (select B.id1, B.id2 from B); where the main select returns those values for which A.id coincides with either B.id1 or B.id2. Clearly this solution doesn't work as the cardinality doesn't match in the where clause. How can I overcome this problem? One solution would be to make two sub-queries, one for B.id1 and one for B.id2, but as my sub-query is much longer than in this example I was looking for a more

Which column to put first in index? Higher or lower cardinality?

删除回忆录丶 提交于 2019-12-31 02:51:09
问题 For example, if I have a table with a city and a state column, what is the best way to use the index? Obviously city will have the highest cardinality, so should I put that column first in the index, should I put state or doesn't it matter much? 回答1: MySQL composite index lookups must take place in the order in which the columns are defined within the index. Since you want MySQL to be able to discriminate between records by performing as few comparisons as possible, with all other things

How to determine cardinality of foreign key using mysql

风流意气都作罢 提交于 2019-12-25 20:57:15
问题 I am stuck in a problem where i have to find cardinality of a relationship between tables using mysql. Following this post MySQL: How to determine foreign key relationships programmatically? I have found all tables related to my table and the columns which are foreign key. Now i also want to find the cardinality of relationship i.e. one-to-one, one-to-many or many-to-many. Any ideas or snippets would be highly appreciated 回答1: Let us assume that table A has a foreign key f which refers to the

How to determine cardinality of foreign key using mysql

时光毁灭记忆、已成空白 提交于 2019-12-25 20:56:10
问题 I am stuck in a problem where i have to find cardinality of a relationship between tables using mysql. Following this post MySQL: How to determine foreign key relationships programmatically? I have found all tables related to my table and the columns which are foreign key. Now i also want to find the cardinality of relationship i.e. one-to-one, one-to-many or many-to-many. Any ideas or snippets would be highly appreciated 回答1: Let us assume that table A has a foreign key f which refers to the

How to change arrows in vis.js to chicken feet or cardinality

◇◆丶佛笑我妖孽 提交于 2019-12-24 16:25:41
问题 I am trying to use vis.js to show the structure of an XML or JSON Schema. I would like to show cardinality instead of an arrow. Any suggestions on documentation to view, because I cannot find any. Thanks, Loren 回答1: Each edge has a function that is responsible for drawing arrows: drawArrows . Accordingly, it is possible to redefine its: edge.drawArrows = function drawArrows(ctx, arrowData) { if (this.options.arrows.from.enabled === true) { drawArrowCircle(ctx, this.selected, this.hover,

exist-db cardinality for parameter

情到浓时终转凉″ 提交于 2019-12-24 00:37:21
问题 I am new in exist-db and XQuery. In exist-db I have this site map: The catalog "registranten" contains the catalog "data" (with xml-files) and the two files "regBasic.xql" and "regSearch.xql". I am trying to search in the xml-files using the script regSearch.xql: xquery version "3.0"; declare option exist:serialize "method=xhtml media-type=text/html"; declare variable $pageTitle := "Resultat"; declare variable $searchphrase := request:get-parameter("searchphrase", ()); <html> <head> <meta

PostgreSQL: How to implement minimum cardinality?

给你一囗甜甜゛ 提交于 2019-12-21 03:55:13
问题 As answered in this question: Cardinality in PostgreSQL, cardinality is enfforced using constraints. Cardinality rules define the allowable counts of the relationships – one-to-many, many-to-many, etc. Many-to-many is achieved using join-tables and one-to-many using FOREIGN KEY. But how can one implement one-to-one_or_many (one-to-1+) relationship. Which is same as to ask: How can I enforce minimum cardinality in PostgreSQL? A practical situation would be where one needs to store say address