'2017/06/17'에 해당되는 글 7건

  1. 2017.06.17 데이터베이스 정규화 (DB normalization)
  2. 2017.06.17 18. palindromeRearranging 1
  3. 2017.06.17 17. arrayChange 1
  4. 2017.06.17 16. areSimilar 1
  5. 2017.06.17 15. addBorder 1
  6. 2017.06.17 14. alternatingSums 1
  7. 2017.06.17 13. reverseParentheses 1
데이터베이스2017. 6. 17. 23:49

위키피디아를 많이 참조했습니다.

매우 간단하게 요약.

 

먼저 정규화(Normalization)란 무엇일까?

- 정규화란

관계형 데이터베이스(테이블간에 관계를 맺을 수 있는 상황)에서 중복을 최소화 하기 위해서

데이터를 구조화 하는 작업.

 

 

1NF, 2NF, 3NF, BCNF, 4NF, 5NF, 6NF 가 있으며

보통 3NF 가 되었으면 ‘정규화 되었다’ 라고 한다.

하지만 실무에서는 대규모 데이터 처리시 성능(Performance)향상을 위해 정규화를 안쓰거나 낮은 수준의 정규화를 만족하는 경우가 많다.

예를 들어서 어떤 고객의 정보를 2개의 테이블로 나누어 두었다고 했을 때 정보를 불러오려면 2개의 테이블에 각각 접근해야 하므로 부하(load)가 걸린다.
하지만 하나의 테이블에 몰아두었을 경우 당연히 더 빠른 성능을 보장한다. (아래의 그림 1(비 정규화), 그림 2(1NF 정규화) 참고)

 

1NF(First Normal Form) : 행과 열의 순서에 영향을 받지 않으며 (원래 DB 는 영향을 안받는다.), 모든 항목에 값이 있어야하며(NULL 허용안함), 중복 기능 열이 없어야 한다.
e1
<그림 1 : NULL 값도 있으며, 같은 기능을 하는 열(TEL 1, TEL 2, TEL 3)이 있어서 1NF아님>

 

 
e2
<그림 2 : NULL값 없고, 중복 기능열도 없음. 1NF 충족. (이 경우 2NF, 3NF 도 충족하는데 이건 아래에서 다 이해하고 다시 살펴보기 바람>

 

 

 

2NF(Second Normal Form) : 이행적 함수 종속이 있을 경우, 그것을 쪼갬.

즉 정적인 데이터에서 한 필드가 다른 필드를 정의할 수 있을 때
e3
<그림 : 종업원 필드가 근무지 필드에 영향을 준다. 종업원-근무지 를 따로 꺼낼 수 있다. 좀 더 멋지게(어렵게) 표현하자면, 근무지 필드가 종업원 필드에 함수종속적 이므로 분리하여야 한다.>
e4
<그림 : 함수 종속적인 필드를 분리. 2NF 만족(물론 1NF도)>

 

 

3NF(Third Normal Form) : 계산열 제거.

다른 열의 값을 계산해서 해당 필드에 가지고 있다.

mysql, mssql, oracle 모두 가능하다.

계산되는 열은 (개발자의 관점에서 보는 테이블 열에서) 제거한다.
e5
<그림 : 1NF만족. 2NF는 주민등록번호를 따로 분리할 수 있는지 봤는데 PK인 고객번호와 역할이 동일하므로 분리 안되더라. 무튼 2NF도 만족>

이 상황에서 계산 가능한 열을 삭제.

2NF 연결되는 것 분리 후에 3NF 계산할 수 있는 것은 삭제하면 된다.
e6
<그림 : 3 정규화 하는 모습. 삭제된 필드는 계산하여 복구 할 수 있으므로 계산열(계산필드)로 처리하거나 쿼리시 관련 계산을 하면 된다>

 

 

 

자료 참조 :

데이터베이스 정규화 - http://ko.wikipedia.org/wiki/%EB%8D%B0%EC%9D%B4%ED%84%B0%EB%B2%A0%EC%9D%B4%EC%8A%A4_%EC%A0%95%EA%B7%9C%ED%99%94

제 3 정규화 - http://www.officetutor.com/column/kkk-db/kkk_12.htm

'데이터베이스' 카테고리의 다른 글

JOIN 간단 정리  (0) 2017.03.23
데이터베이스 백업 및 복원  (0) 2017.03.23
정렬하면 1다음 11이 나올때 해결책  (0) 2017.03.23
기본적인 명령어 모음  (0) 2017.03.23
Posted by EL2A
알고리즘(CF)2017. 6. 17. 21:21

Given a string, find out if its characters can be rearranged to form a palindrome.




Example

For inputString = "aabb", the output should be
palindromeRearranging(inputString) = true.

We can rearrange "aabb" to make "abba", which is a palindrome.




Code

function palindromeRearranging(inputString) {

   

}

'알고리즘(CF)' 카테고리의 다른 글

20. arrayMaximalAdjacentDifference  (1) 2017.06.18
19. areEquallyStrong  (1) 2017.06.18
17. arrayChange  (1) 2017.06.17
16. areSimilar  (1) 2017.06.17
15. addBorder  (1) 2017.06.17
Posted by EL2A
알고리즘(CF)2017. 6. 17. 21:20

You are given an array of integers. On each move you are allowed to increase exactly one of its element by one. Find the minimal number of moves required to obtain a strictly increasing sequence from the input.




Example

For inputArray = [1, 1, 1], the output should be
arrayChange(inputArray) = 3.




Code

function arrayChange(inputArray) {

   

}

'알고리즘(CF)' 카테고리의 다른 글

19. areEquallyStrong  (1) 2017.06.18
18. palindromeRearranging  (1) 2017.06.17
16. areSimilar  (1) 2017.06.17
15. addBorder  (1) 2017.06.17
14. alternatingSums  (1) 2017.06.17
Posted by EL2A
알고리즘(CF)2017. 6. 17. 21:19

wo arrays are called similar if one can be obtained from another by swapping at most one pair of elements in one of the arrays.

Given two arrays a and b, check whether they are similar.




Example

  • For a = [1, 2, 3] and b = [1, 2, 3], the output should be
    areSimilar(a, b) = true.

    The arrays are equal, no need to swap any elements.

  • For a = [1, 2, 3] and b = [2, 1, 3], the output should be
    areSimilar(a, b) = true.

    We can obtain b from a by swapping 2 and 1 in b.

  • For a = [1, 2, 2] and b = [2, 1, 1], the output should be
    areSimilar(a, b) = false.

    Any swap of any two elements either in a or in b won't make a and b equal.





Code

function areSimilar(a, b) {

    

}

'알고리즘(CF)' 카테고리의 다른 글

18. palindromeRearranging  (1) 2017.06.17
17. arrayChange  (1) 2017.06.17
15. addBorder  (1) 2017.06.17
14. alternatingSums  (1) 2017.06.17
13. reverseParentheses  (1) 2017.06.17
Posted by EL2A
알고리즘(CF)2017. 6. 17. 21:18


Given a rectangular matrix of characters, add a border of asterisks(*) to it.




Example

For

picture = ["abc",
           "ded"]

the output should be

addBorder(picture) = ["*****",
                      "*abc*",
                      "*ded*",
                      "*****"]





Code

function addBorder(picture) {

   

}

'알고리즘(CF)' 카테고리의 다른 글

17. arrayChange  (1) 2017.06.17
16. areSimilar  (1) 2017.06.17
14. alternatingSums  (1) 2017.06.17
13. reverseParentheses  (1) 2017.06.17
12. sortByHeight  (1) 2017.06.08
Posted by EL2A
알고리즘(CF)2017. 6. 17. 21:16

Several people are standing in a row and need to be divided into two teams. The first person goes into team 1, the second goes into team 2, the third goes into team 1 again, the fourth into team 2, and so on.

You are given an array of positive integers - the weights of the people. Return an array of two integers, where the first element is the total weight of team 1, and the second element is the total weight of team 2 after the division is complete.




Example

For a = [50, 60, 60, 45, 70], the output should be
alternatingSums(a) = [180, 105].




Code

function alternatingSums(a) {

    

}

'알고리즘(CF)' 카테고리의 다른 글

16. areSimilar  (1) 2017.06.17
15. addBorder  (1) 2017.06.17
13. reverseParentheses  (1) 2017.06.17
12. sortByHeight  (1) 2017.06.08
11. isLucky  (1) 2017.06.08
Posted by EL2A
알고리즘(CF)2017. 6. 17. 21:15

You have a string s that consists of English letters, punctuation marks, whitespace characters, and brackets. It is guaranteed that the parentheses in s form a regular bracket sequence.

Your task is to reverse the strings contained in each pair of matching parentheses, starting from the innermost pair. The results string should not contain any parentheses.




Example

For string s = "a(bc)de", the output should be
reverseParentheses(s) = "acbde".




Code

function reverseParentheses(s) {


}

'알고리즘(CF)' 카테고리의 다른 글

15. addBorder  (1) 2017.06.17
14. alternatingSums  (1) 2017.06.17
12. sortByHeight  (1) 2017.06.08
11. isLucky  (1) 2017.06.08
10. commonCharacterCount  (1) 2017.06.08
Posted by EL2A