database-normalization

First normal form and temporal data

纵然是瞬间 提交于 2020-01-01 19:06:16
问题 The first normal form says that row ordering should not matter. Does this mean that a table with date as part of the key is not 1NF? e.g. Consider a table of ticker prices where date/time is part of the PK. In this case, you get the last price by ordering the data by date and selecting the top 1 row. Does this mean that for to fulfill 1NF you need to split the table into: 1) TickerCurrentPrice (1 row per ticker) 2) TickerHistoricalPrice Thanks 回答1: 1NF is aspect of a table representing a

Database “supertable” vs more tables vs generic table

寵の児 提交于 2020-01-01 13:35:48
问题 I'm trying to decide on a database design. More specifically, this is a sub-part of a larger design. Basically, there are "Locations" - each location can have any number of sensors associated with it, and it can have a logger (but only 1). I have sensor readings and I have logger readings, each different enough I think to warrant separate tables. If a sensor reading goes out of range, an alert is generated. While a sensor reading stays out of range, they keep being associated with that alert

Lossless Join and Decomposition From Functional Dependencies

倾然丶 夕夏残阳落幕 提交于 2019-12-31 10:49:27
问题 Suppose the relation R( K, L, M, N, P) , and the functional dependencies that hold on R are: - L -> P - MP -> K - KM -> P - LM -> N Suppose we decompose it into 3 relations as follows: - R1(K, L, M) - R2(L, M, N) - R3(K, M, P) How can we tell whether this decomposition is lossless? I used this example R1 ∩ R2 = {L, M}, R2 ∩ R3 = {M}, R1 ∩ R3 = {K,M} we use functional dependencies, and this is not lossless in my opinion, but a little bit confused. 回答1: It helps if we demystify the concept of

What is a good KISS description of Boyce-Codd normal form?

非 Y 不嫁゛ 提交于 2019-12-31 08:29:29
问题 What is a KISS (Keep it Simple, Stupid) way to remember what Boyce-Codd normal form is and how to take a unnormalized table and BCNF it? Wikipedia's info: not terribly helpful for me. 回答1: Chris Date's definition is actually quite good, so long as you understand what he means: Each attribute Your data must be broken into separate, distinct attributes/columns/values which do not depend on any other attributes. Your full name is an attribute. Your birthdate is an attribute. Your age is not an

How do I not normalize continuous data (INTS, FLOATS, DATETIME, …)?

冷暖自知 提交于 2019-12-31 04:48:07
问题 According to my understanding - and correct me if I'm wrong - "Normalization" is the process of removing the redundant data from the database-desing However, when I was trying to learn about database optimizing/tuning for performance, I encountered that Mr. Rick James recommend against normalizing continuous values such as (INTS, FLOATS, DATETIME, ...) "Normalize, but don't over-normalize." In particular, do not normalize datetimes or floats or other "continuous" values. source Sure purists

Deciding whether a relation is 3NF or 2NF

坚强是说给别人听的谎言 提交于 2019-12-31 03:58:07
问题 From the Database Management Systems book: given the relation SNLRWH (each letter denotes an attribute) and the following functional dependencies: S->SNLRWH (S is the PK) R->W My attempt: First, it is not 3NF: for the second FD, neither R contains W, nor R contains a key, nor W is part of a key. Second, it is/not 2NF. If we examine the second FD, W is dependent on R, which in turn is not part of a key. STUCK. 回答1: 2NF is violated if some proper subset of a candidate key appears as a

MySQL Enforce Unique constraint across a Combination of Rows

不羁的心 提交于 2019-12-31 02:55:11
问题 I am refining a Search Auto-suggestion system, and after a few iterations and Normalization, have the following set of tables: DB Fiddle : https://www.db-fiddle.com/f/b1FvGDkBMQXkREaMh3pHKi/0 Table 1: keywords - It stores a list of alphanumeric (relevant) keywords. Relevant details are: CREATE TABLE keywords ( keyword_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, keyword VARCHAR(32) NOT NULL /* Other fields eg: ranking, weights, etc */ ) engine = innodb; | keyword_id | keyword | | ----

Normalization on relational schema with no functional dependencies

梦想与她 提交于 2019-12-25 18:54:44
问题 R = ( A, B, C, D ) - No functional dependencies are valid in the relational schema R For the above relational, what is the highest normal form? I have a question where i am supposed to identify the highest normal form and decompose it into BCNF if it is not in BCNF. 回答1: If no valid FDs holds (a part from the trivial dependencies), then the only candidate key is ABCD, and the relation is both in 3NF and BCNF. 来源: https://stackoverflow.com/questions/59008573/normalization-on-relational-schema

How to best represent an attribute that appears in both master and detail records?

匆匆过客 提交于 2019-12-25 18:41:40
问题 I have a simple master-detail relation in which both entities share an attribute (which happens to be a timestamp, and is not part of the key.) The detail records are ranked (by some other attribute) from top to bottom. The business rule is: (a) If there are detail records, apply the timestamp of the top one to the master; (b) otherwise, the master must have a timestamp regardless; and (c) (rarely) permit the master to have a timestamp that differs from the that of the top detail records. The

Normalize a table with a two-column primary key and one other column

一曲冷凌霜 提交于 2019-12-25 12:04:23
问题 My DataTable has 3 columns: A, B and C. None are guaranteed to have unique entries, in non-trivial cases every column will have non-unique entries. The combination of {A, B} is guaranteed to be unique. Because ADO.NET DataTable allows using multiple columns as the primary key, I use A and B as my primary key. A vs B represents a matrix with 0 as the default value, so it's possible for me to guarantee that entries of B will come from a finite pool and for each entry of A, every possible {A, B}