database-schema

Continuous Integration, best practice to input actual test data into database, using Propel ORM

非 Y 不嫁゛ 提交于 2019-11-28 06:48:21
问题 I used Propel ORM to duplicate a table schema, in order to do continuous integration, but Propel only gets me a fully fleshed out schema, it doesn't get me test data (or basic necessary data at all). How do I get the data from a live/test database with a version controlled propel-gen Propel ORM ecosystem? 回答1: They say that "best practice" in anything at all doesn't exist - it's so subjective that one ought to settle for one of several forms of "good practice" instead. I think the below

Is it possible to create a column with a UNIX_TIMESTAMP default in MySQL?

旧街凉风 提交于 2019-11-28 04:54:24
I'm trying to do this, but it seems like MySQL isn't allowing me. Is there a solution to this issue or am I expected to always include the function in my INSERT queries? CREATE TABLE foo( created INT NOT NULL DEFAULT UNIX_TIMESTAMP() ) I'm aware of the TIMESTAMP type that accepts a CURRENT_TIMESTAMP default, but my client insisted on using epoch time in the database. The way MySQL implements the TIMESTAMP data type, it is actually storing the epoch time in the database. So you could just use a TIMESTAMP column with a default of CURRENT_TIMESTAMP and apply the UNIX_TIMESTAMP() to it if you want

DB2 Query to retrieve all table names for a given schema

和自甴很熟 提交于 2019-11-28 04:20:51
I'm just looking for a simple query to select all the table names for a given schema. For example, our DB has over 100 tables and I need to find any table that contains the sub-string “CUR”. I can use the like command once I have all the tables. select * from sysibm.systables where owner = 'SCHEMA' and name like '%CUR%' and type = 'T'; This will give you all the tables with CUR in them in the SCHEMA schema. See here for more details on the SYSIBM.SYSTABLES table. If you have a look at the navigation pane on the left, you can get all sorts of wonderful DB2 metatdata. Note that this link is for

How do I get an Oracle SCHEMA as DDL scripts with DBMS_METADATA (and SCHEMA_EXPORT)

那年仲夏 提交于 2019-11-28 03:29:55
问题 I am having troubles to extract the DDL for a given schema with DBMS_METADATA, probably because my understanding of it is wrong. Here's what I basically do: set termout off create table copy_dml_schema(c clob, i number); declare m number; t number; e number; c clob; i number := 0; begin e := dbms_metadata.session_transform; dbms_metadata.set_transform_param (e, 'REF_CONSTRAINTS' , false ); dbms_metadata.set_transform_param (e, 'CONSTRAINTS_AS_ALTER', true ); dbms_metadata.set_transform_param

Designing a SQL schema for a combination of many-to-many relationship (variations of products)

蹲街弑〆低调 提交于 2019-11-28 03:12:57
I hope the title is somewhat helpful. I'm using MySQL as my database I am building a database of products and am not sure how to handle storing prices/SKU of variations of a product. A product may have unlimited variations, and each variation combination has its own price/SKU/etc.. This is how I have my products/variations table set up at the moment: PRODUCTS +--------------------------+ | id | name | description | +----+------+--------------+ | 1 | rug | a cool rug | | 2 | cup | a coffee cup | +----+------+--------------+ PRODUCT_VARIANTS +----+------------+----------+-----------+ | id |

Is it OK to update a production database with EF migrations?

痴心易碎 提交于 2019-11-28 03:08:05
According to this blog post most companies using EF Migrations are supposedly not updating the database schema of production databases with EF migrations. Instead the blog post's author recommends to use Schema update scripts as part of the deployment process. I've used Schema update scripts for a few years now and while they work, I was planning to use EF migrations instead in the future for the following reasons: Faster deployment, less downtime A simpler deployment procedure Much easier migration of existing data than it would be possible with T-SQL A more comprehensible syntax of the

Differences between key, superkey, minimal superkey, candidate key and primary key

喜夏-厌秋 提交于 2019-11-28 02:41:21
I'm new to MySQL, and I'm really confused about the different terms that I've encountered. I tried googling the answer but the results are really confusing and when I try and understand it just seems like they are the same thing. What exactly are the differences among key, superkey, minimal superkey, candidate key and primary key? bHaRaTh Here I copy paste some of the information that I have collected Key A key is a single or combination of multiple fields. Its purpose is to access or retrieve data rows from table according to the requirement. The keys are defined in tables to access or

Adding an one-out-of-two not null constraint in postgresql

戏子无情 提交于 2019-11-28 02:27:13
问题 If I have a table in Postgresql: create table Education ( id integer references Profiles(id), finished YearValue not null, started YearValue, qualification text, schoolName text, studiedAt integer references Organizations(id), primary key (id) ); I need to make a constraint so that either schoolName or studiedAt needs to not be null (one of them has to have information in it). How do I do this? 回答1: You can use a check constraint e.g. constraint chk_education check (schoolName is not null or

Foreign Key Referencing Multiple Tables

有些话、适合烂在心里 提交于 2019-11-28 01:57:10
问题 I have a column with a uniqueidentifier that can potentially reference one of four different tables. I have seen this done in two ways, but both seem like bad practice. First, I've seen a single ObjectID column without explicitly declaring it as a foreign key to a specific table. Then you can just shove any uniqueidentifier you want in it. This means you could potentially insert IDs from tables that are not part of the 4 tables I wanted. Second, because the data can come from four different

Dynamically changing schema in Entity Framework Core

亡梦爱人 提交于 2019-11-27 21:28:12
UPD here is the way I solved the problem. Although it's likely to be not the best one, it worked for me. I have an issue with working with EF Core. I want to separate data for different companies in my project's database via schema-mechanism. My question is how I can change the schema name in runtime? I've found similar question about this issue but it's still unanswered and I have some different conditions. So I have the Resolve method that grants the db-context when necessary public static void Resolve(IServiceCollection services) { services.AddIdentity<ApplicationUser, IdentityRole>()