database-schema

Break atomicity rule storing list of items when there is no reason to query about items? Verses join table that requires whole join table be scanned

社会主义新天地 提交于 2019-12-01 14:42:47
This specific case is regarding lists, and items. The same item may belong to multiple lists, and each list has many items. Option A (the "proper" way as I understand it): Make a join table, which has list_ID and item_ID. When I want all the items in a list query for list_ID. Option B (break the atomicity rule): Make a list table. Primary Key, and either repeating columns or non-atomic columns. As I understand it both of these deviations suffer the exact same drawbacks, which is the inability to inefficiently query on items. As I understand it, normalizing a database to NF-1 would be making

Logical Expressions rules in relational datamodel

◇◆丶佛笑我妖孽 提交于 2019-12-01 12:37:21
I have a logical expression say c=a+b*d something like Is it possible to achieve this in a relational datamodel setup? I do not want to hardcode the rule in a varchar field. I am looking at chaining the rules. Something on the lines of a rule engine however I want to do it purely using relational database. Such an expression is a tree. Your example, expressed as a tree, is = c + a * b d The leaves of the tree are the primitive symbols a, b, ..., while the roots of the (sub)trees are the operators. A simple relational database structure to represent such trees is node(id, operator, left

Are there performance advantages by splitting a Django model/table into two models/tables?

余生颓废 提交于 2019-12-01 10:47:15
问题 In SO question 7531153, I asked the proper way to split a Django model into two—either using Django's Multi-table Inheritance or explicitly defining a OneToOneField. Based Luke Sneeringer's comment, I'm curious if there's a performance gain from splitting the model in two. The reason I was thinking about splitting the model in two is because I have some fields that will always be completed, while there are other fields that will typically be empty (until the project is closed). Are there

Logical Expressions rules in relational datamodel

妖精的绣舞 提交于 2019-12-01 10:35:48
问题 I have a logical expression say c=a+b*d something like Is it possible to achieve this in a relational datamodel setup? I do not want to hardcode the rule in a varchar field. I am looking at chaining the rules. Something on the lines of a rule engine however I want to do it purely using relational database. 回答1: Such an expression is a tree. Your example, expressed as a tree, is = c + a * b d The leaves of the tree are the primitive symbols a, b, ..., while the roots of the (sub)trees are the

Extendable Database Schema - How to store the extendable attribute values

末鹿安然 提交于 2019-12-01 10:34:29
We are using SQL Server 2008 and one of the requirements is to have extendable user defined attributes on the entities that are defined for the system. For example, we might have a entity called Doctor, we want the admins of the system to be able to define extra attributes that normally are not in the system. These attributes will most likely be needed as query criteria linking parent or joiner tables. There will be tables that define the attributes (Name, description, type) and so forth, but my question is on the storage of the actual data values. Im not a DBA (just a programmer pretending to

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

家住魔仙堡 提交于 2019-12-01 08:28:27
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? 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 qualifies for that label — and ultimately it works well for me. I've been using PHPUnit for about a year, and

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

北城余情 提交于 2019-12-01 06:06:29
问题 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

How to design a database schema for storing text in multiple languages?

限于喜欢 提交于 2019-12-01 05:57:39
We have a PostgreSQL database. And we have several tables which need to keep certain data in several languages (the list of possible languages is thankfully system-wide defined). For example lets start with: create table blah (id serial, foo text, bar text); Now, let's make it multilingual. How about: create table blah (id serial, foo_en text, foo_de text, foo_jp text, bar_en text, bar_de text, bar_jp text); That would be good for full-text search in Postgres. Just add a tsvector column for each language. But is it optimal? Maybe we should use another table to keep the translations? Like:

SQL Server Compare Schema in Visual Studio 2017

眉间皱痕 提交于 2019-12-01 05:19:58
I am attempting to compare schemas of two databases on the same server. The two databases are named benchmarkdb and benchmarkdb_dev . In Visual Studio 2017, I go to Tools > SQL Server > New Schema Compare... From both drop down menus labeled "Select Source" and "Select Target" (as seen in the picture below), I want to select benchmarkdb as source and bencmarkdb_dev as target. After clicking to select a source, the "Select Source Schema" pops up, and I clicked the "Select Connection..." button, which brought another popup. The newest popup (the one on the right in the picture below) shows both

How to design a database schema for storing text in multiple languages?

人走茶凉 提交于 2019-12-01 03:46:43
问题 We have a PostgreSQL database. And we have several tables which need to keep certain data in several languages (the list of possible languages is thankfully system-wide defined). For example lets start with: create table blah (id serial, foo text, bar text); Now, let's make it multilingual. How about: create table blah (id serial, foo_en text, foo_de text, foo_jp text, bar_en text, bar_de text, bar_jp text); That would be good for full-text search in Postgres. Just add a tsvector column for