rdbms

When/Why to use Cascading in SQL Server?

雨燕双飞 提交于 2019-12-17 02:55:13
问题 When setting up foreign keys in SQL Server, under what circumstances should you have it cascade on delete or update, and what is the reasoning behind it? This probably applies to other databases as well. I'm looking most of all for concrete examples of each scenario, preferably from someone who has used them successfully. 回答1: Summary of what I've seen so far: Some people don't like cascading at all. Cascade Delete Cascade Delete may make sense when the semantics of the relationship can

NoSql vs Relational database

拟墨画扇 提交于 2019-12-17 02:39:10
问题 Recently NoSQL has gained immense popularity. What are the advantages of NoSQL over traditional RDBMS ? 回答1: Not all data is relational. For those situations, NoSQL can be helpful. With that said, NoSQL stands for "Not Only SQL". It's not intended to knock SQL or supplant it. SQL has several very big advantages: Strong mathematical basis. Declarative syntax. A well-known language in Structured Query Language (SQL). Those haven't gone away. It's a mistake to think about this as an either/or

Drop a role with privileges

我是研究僧i 提交于 2019-12-14 03:59:39
问题 This looks like a very basic need, but I do not find any quick and suitable answer. I have a role in Postgres which has privileges to many other tables in various databases. I need to drop this role. I have one postgres instance and then many databases on top of it. SELECT DISTINCT 'REVOKE ALL ON TABLE ' || table_schema || '.' || table_name || ' FROM ' || r.param_role_name || ';' FROM information_schema.table_privileges CROSS JOIN (SELECT 'some_role_name'::text AS param_role_name) r WHERE

SQL query max(), count()

戏子无情 提交于 2019-12-14 02:15:33
问题 the database schema looks like employee(employee_name,street,city) works(employee_name,company_name,salary) company(company_name,city) manages(employee_name,manager_name) the query needed to do is: find the company that has the most employees. I could find out the maximum count by the query: SELECT max( cnt ) max_cnt FROM ( SELECT count( employee_name ) cnt, company_name FROM works GROUP BY company_name )w1; But now I can't find out the name of the company. If anyone has some idea please

Difficult cross-tab query

倾然丶 夕夏残阳落幕 提交于 2019-12-13 19:27:51
问题 Tied myself a bit up in knots in the development of a relatively complicated relational database. Purpose of database is to allow managers to arrange meetings with representatives (or groups of representatives) from particular companies. Naturally the table, outlining the details relating to arranged meetings, is of utmost importance. Unfortunately most of its information is nigh impossible for users to parse as the fields are merely returning the numerical fields of other tables. So really

how to optimize this sql insertion php code?

∥☆過路亽.° 提交于 2019-12-13 16:22:39
问题 I have mysql database and I want to insert about 40'000 rows into it from PHP code , but my code takes more than 15 minutes to insert the rows, is there any chances to optimize it? where is my problem(PHP code / database design) ? here are the details: - the row data are stored in a utf-8 txt file the values separated by "\t" tab character and every row sets in one line of the file, like this string view: "value1\tvalue2\tvalue3\value4\value5\r\nvalue1\tvalue2\tvalue3\value4\value5\r\nvalue1

Why are RDBMS considered Available (CA) for CAP Theorem

非 Y 不嫁゛ 提交于 2019-12-13 11:53:56
问题 If I understand the CAP Theorem correctly, availability means that the cluster continues to operate even if a node goes down. I've seen a lot of people (http://blog.nahurst.com/tag/guide) list RDBMS as CA, but I do not understand how RBDMS is available, as if a node goes down, the cluster must go down to maintain consistency. My only possible answer to this has been that most RDBMS are a single node, so there is no "non-failing" node. But, this seems to be a technicality, not true

Is a hash index never a clustering index?

落爺英雄遲暮 提交于 2019-12-13 08:47:08
问题 From Database System Concepts We use the term hash index to denote hash file structures as well as secondary hash indices. Strictly speaking, hash indices are only secondary index structures . A hash index is never needed as a clustering index structure , since, if a file itself is organized by hashing, there is no need for a separate hash index structure on it. However, since hash file organization provides the same direct access to records that indexing provides, we pretend that a file

Canonical cover is in which normal form?

依然范特西╮ 提交于 2019-12-13 07:00:04
问题 I want to know which normal form a canonical cover is in. I know before doing normalization we find the canonical cover so I think it is in first normal form. But it may be in no normal form as the definition of 1NF by Wikipedia is no row should have a duplicate: First normal form enforces below criteria: Eliminate repeating groups in individual tables. Create a separate table for each set of related data. Identify each set of related data with a primary key 回答1: Normal forms apply to

Where would a scaled relational DB fall in the CAP theorem?

纵然是瞬间 提交于 2019-12-13 04:45:52
问题 If you have scaled SQL server with one DB for writes and multiple DBs for reads. Wouldn't there be a delay for data to be replicated from the write DB to the to other read databases? In which case isn't the data inconsistent? So where would a scaled relational DB fall in the CAP theorem? Update: In relational DBs consistency means there wont be partial updates. For example if someone transfers money from one account to another and the whole thing is a part of one transaction, it wont happen