rdbms

soft delete common attributes with regards to cascade recovery

十年热恋 提交于 2019-12-11 11:09:03
问题 What type of fields are generally used to accompany soft delete? Any of these, any others? bool IsDeleted // nice because the default value is 0 (no) just in case date DateDeleted // is this a common one? date DateCreated // more of a temporal db aspect date DateModified // same with respect to created The reason I ask is that when using soft-deletes, cascading must still be implemented in order to maintain integrity. However, the real trick is not cascade deleting, which is rather easy. The

RDBMS vs file system for file storage

﹥>﹥吖頭↗ 提交于 2019-12-11 08:34:48
问题 Are there any advantages of storing entire files in an RDBMS over storing the files in the file system with references to the file path in the RDBMS? Which approach shall be faster? When do I choose one over the other? Does it matter which file system is in use? (say ext3) I do not expect the files to change at all. The files may be json or xml or might be pdf (less likely). Also, there might be no need to refer to these files often. They are only meant for archival. Thank you. 回答1: Given

Can't manage to get the Star-Schema DBMS benchmark data generator to run properly

狂风中的少年 提交于 2019-12-11 08:08:12
问题 One of the commonly (?) used DBMS benchmarks is called SSB, the Star-Schema Benchmark. To run it, you need to generate your schema, i.e. your tables with the data in them. Well, there's a generator program you can find in all sorts of places (on github): https://github.com/rxin/ssb-dbgen https://code.google.com/p/gpudb/source/checkout (then under tests/ssb/dbgen or something) https://github.com/electrum/ssb-dbgen/ and possibly elsewhere. I'm not sure those all have exactly the same code, but

PostgreSQL force standard SQL syntax

ぐ巨炮叔叔 提交于 2019-12-11 04:15:28
问题 Is it possible to have Postgres reject queries which use its proprietary extensions to the SQL language? e.g. select a::int from b; should throw an error, forcing the use of proper casts as in select cast(a as int) from b; Perhaps more to the point is the question of whether it is possible to write SQL that is supported by all RDBMS with the same resulting behaviour? 回答1: PostgreSQL has no such feature. Even if it did, it wouldn't help you tons because interpretations of the SQL standard vary

Fetching rows from multiple tables with UNION ALL or using one table in production?

人走茶凉 提交于 2019-12-11 03:06:25
问题 I know that for relational database like Postgresql using separated tables would be more efficient but I'm concerning for performance issues because the most executed query will fetch rows from multiple tables using UNION ALL . I have to option to handle this problem. First one is: table1 -> column1, column2 table2 -> column1, column2 table3 -> column1, column2, column3 In this solution I have to use 3 different query merged with UNION ALL in production and this query will be performed a user

How can I correctly order by this varchar field representing a multiple level order using SQL?

谁说我不能喝 提交于 2019-12-11 00:38:55
问题 I am not so into DB and I am finding the following problem working on a query on a SQL Server DB of an old legacy application. I state that unfortunately I can't change the database structure\fields type (that are pretty ugly) I have the following situation: SELECT [Sottocategoria] ,[IdSottocategoria] ,[IdCategoria] ,[Note] FROM [dbo].[PROT_TITOLARIO] where IdCategoria = '5' order by IdSottocategoria and I am obtaining something like this: I have highlighted my output error. As you can see I

Having a foreign key as the primary key in a child table

谁说胖子不能爱 提交于 2019-12-10 22:45:26
问题 In a One to Many association between a Parent Table and Child Table. Is it ok to make the Foreign key on the Child table as the Primary key on the same child table. Just working my way through DBMS and would appreciate expert views on these type of designs. What are the Pros and Cons? 回答1: If you mean one parent row maps to many child rows, then you won't be able to do that. Primary key values come with unique key constraints; if you need multiple child rows to reference the same parent,

Insert null into not null column with default FIREBIRD

三世轮回 提交于 2019-12-10 21:52:45
问题 Inserting null into not null column with default is giving me a validation error instead of taking the default value. I don't want to make on before triggers to all of the tables. Is there any other way to do this? Firebird 2.1.3 回答1: The default value is used when you omit a field in the insert, not when you include the field with a null value. Example: Uses default for Name : insert into SomeTable (Id) values (42) Tries to insert null into Name : insert into SomeTable (Id, Name) values (42,

How to have a primary key with null values using empty string?

孤街浪徒 提交于 2019-12-10 18:50:02
问题 I have a table in which I need both the values to be primary because I am referencing this combination as foreign key in the other tables. Table definition and the data I need to put are as follows create table T1 ( sno number(10), desc varchar2(10), constraint T1_PK primary key(sno,desc) ) DATA to put sno | desc --------------------------- 100 | "hundred" 000 | null 120 | "one twenty" 123 | "" <EMPTY STRING> 000 | "" <EMPTY STRING> Problem here is desc can be sometimes be null. Primary key

Improving query performance by using views

╄→尐↘猪︶ㄣ 提交于 2019-12-10 18:49:47
问题 I have a large table with 10+ millions records in a SQL Server database. The table contains certain type of data for all 50 states in the US. So if I create 50 views, one for each state, from this table, would the performance of making queries from my application be improved? Other suggestions? 回答1: No. A view is a macro that expands so the same tables end up in the plan anyway. Unless it's indexed. 50 indexed views is most likely overkill. If you have slow performance with 50 million rows