database-normalization

Is database normalization still necessary?

*爱你&永不变心* 提交于 2019-11-29 06:55:58
问题 Is database normalization still "the thing?" When I studied during a databases course we were taught all levels of normalization and were said that we must always do it. Now, with all the NoSQL movement, it seems normalization is no longer the thing to do? 回答1: It depends on what type of application(s) are using the database. For OLTP apps (principally data entry, with many INSERTs, UPDATEs and DELETES, along with SELECTs), normalized is generally a good thing. For OLAP and reporting apps,

Convert JSON array in MySQL to rows

[亡魂溺海] 提交于 2019-11-29 05:35:12
UPDATE: This is now possible in MySQL 8 via the JSON_TABLE function: https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html I'm loving the new JSON functions in MySQL 5.7, but running into a block trying to merge values from JSON into a normal table structure. Grabbing JSON, manipulating and extracting arrays from it etc. is simple. JSON_EXTRACT all the way. But what about the inverse, going from a JSON array to rows? Perhaps I am dense on the existing MySQL JSON functionality, but I haven't been able to figure that one out. For example, say I have a JSON array and want to insert a

Star schema, normalized dimensions, denormalized hierarchy level keys

五迷三道 提交于 2019-11-28 21:32:59
Given the following star schema tables. fact, two dimensions, two measures. # geog_abb time_date amount value #1: AL 2013-03-26 55.57 9113.3898 #2: CO 2011-06-28 19.25 9846.6468 #3: MI 2012-05-15 94.87 4762.5398 #4: SC 2013-01-22 29.84 649.7681 #5: ND 2014-12-03 37.05 6419.0224 geography dimension, single hierarchy, 3 levels in hierarchy. # geog_abb geog_name geog_division_name geog_region_name #1: AK Alaska Pacific West #2: AL Alabama East South Central South #3: AR Arkansas West South Central South #4: AZ Arizona Mountain West #5: CA California Pacific West time dimension, two hierarchies, 4

Decision between storing lookup table id's or pure data

烈酒焚心 提交于 2019-11-28 17:59:21
I find this comes up a lot, and I'm not sure the best way to approach it. The question I have is how to make the decision between using foreign keys to lookup tables, or using lookup table values directly in the tables requesting it, avoiding the lookup table relationship completely. Points to keep in mind: With the second method you would need to do mass updates to all records referencing the data if it is changed in the lookup table. This is focused more towards tables that have a lot of the column's referencing many lookup tables.Therefore lots of foreign keys means a lot of joins every

What is the difference between 3NF and BCNF?

守給你的承諾、 提交于 2019-11-28 15:59:41
Can someone please explain the difference between 3NF and BCNF to me? It would be great if you could also provide some examples. Thanks. Mosty Mostacho The difference between 3NF and BCNF is subtle. 3NF Definition A relation is in 3NF if it is in 2NF and no non-prime attribute transitively depends on the primary key. In other words, a relation R is in 3NF if for each functional dependency X ⟶ A in R, at least one of the following conditions are met: X is a key or superkey in R A is a prime attribute in R Example Given the following relation: EMP_DEPT(firstName, employeeNumber, dateOfBirth,

Drupal Database Structure - Efficient/Inefficient?

假如想象 提交于 2019-11-28 09:37:41
问题 I'm certainly no Drupal expert, but I've schemed and built a few databases before, so am puzzled by the structure of a database a 3rd party team is working on that I had Sequel Pro'd into to add some dummy content. I presume the structure wouldn't be apparent if one were to use Drupal's back end GUI, but I don't have creds, just ftp, and ssh access. I was a bit horrified to see not the single table I would have expected for, say, an Organization, with columns for ID, Name, Address, Email, Zip

Elegant normalization without adding fields, extra table. Best relationship

爷,独闯天下 提交于 2019-11-28 02:17:21
I have 2 tables I am trying to normalize. The problem is I don't want to create an offhand table with new fields, though a link table perhaps works. What is the most elegant way to convey that the "Nintendo" entry is BOTH a publisher and a developer? I don't want "Nintendo" to be duplicated. I am thinking a many-to-many relationship can be key here. I want to stress that I absolutely want the developer and a publisher tables to remain. I don't mind creating a link between the 2 with a new relationship. Here are the 2 tables I am trying to normalize: Below is a solution I tried (I don't like it

Understanding Normalization & Duplicates - I Guess I Don't - Adding Artist & Title Ids [closed]

帅比萌擦擦* 提交于 2019-11-28 01:46:45
I began with a table listing the top 100 songs by date for the years 1958 through 1980. For each date, there are 100 records. Obviously many will be duplicates as a song changes position from week to week. Also, the artists will be duplicated (think Elvis) numerous times. There are ~ 116,000 records in the table. This table had the following fields uniq, date, artist, title, position To eliminate duplicates (normalization as I understand it) I have modified the table so that it now looks like this uniq, date, artistcode, titlecode, position And have two new tables artists and titles. Artists

Convert JSON array in MySQL to rows

南笙酒味 提交于 2019-11-27 23:23:29
问题 UPDATE: This is now possible in MySQL 8 via the JSON_TABLE function: https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html I'm loving the new JSON functions in MySQL 5.7, but running into a block trying to merge values from JSON into a normal table structure. Grabbing JSON, manipulating and extracting arrays from it etc. is simple. JSON_EXTRACT all the way. But what about the inverse, going from a JSON array to rows? Perhaps I am dense on the existing MySQL JSON functionality, but

What exactly does database normalization do?

陌路散爱 提交于 2019-11-27 22:56:40
New to database and so no to get upset with simple questions. As far as my googled and gathered knowledge normalization reduces redundancy of data and increase the performance. But really, I didn't understand what exact reason for dividing the master table into other small tables, applying relationship among them, retrieving the data using all possible unions,subqueries,joins etc., Why can't we have all the data in a single table and retrieve them as on required. I'm little confused. The main reason is to eliminate repetition of data, so for example if you had a user with multiple addresses