상세 컨텐츠

본문 제목

프로그래머 도전기 50일차

프로그래머가 될거야!

by Choyee 2023. 10. 20. 00:09

본문

오늘은

오늘은 비가 내렸습니다

내일부터 추워진다고 하는군요...

아직 컨디션이 돌아오지 않았는데 또 추워진다니

걱정입니다 ㅠㅠ

 

 

 

학원 수업

정규화
제3정규형
1. 제1정규형 - 원인 = 도메인(속성)에 다중 속성값이 있을 때(속성값이 2개이상 있는 경우)
                - 해결 = 속성값을 한개로 만든다(원자값)
2. 제2정규형 - 원인 = 일반 속성이 복합 식별자 중 일부 식별자에 종속되어 있음
                - 해결 = 2개의 테이블로 분리(일부식별자와 속성을 다른 하나의 테이블로 분리 작성)
3. 제3정규형 - 원인 = 어떤 속성이 일반 속성에 종속되어 있는 경우
                            주식별자가 아닌 모든 속성간에는 종속될 수 없다 
                - 해결 = 2개의 테이블로 분리(일부식별자와 속성을 하나의 테이블로 분리 작성)

ROWNUM = SELECT문 결과에 대해서 논리적인 일련번호를 부여
                조회되는 행 수를 제한할 때 사용
                화면에 데이터를 출력할 때 부여되는 논리적 순번

mysql - user = root
           비번 = pw1234

오라클 - user 이름이 db이름과 같음
mysql - user를 만들고 create database mydb를 해야한다
        - 자료형 : varchar, int, date 등
        - db작업 = 사용 db 실행 : use mydb;

 mysql.exe
환경변수 설정 - 내pc -> 우클릭 -> 속성 -> 고급 -> 환경변수 -> 시스템 변수 path -> 편집

0123

-- 계정 : myuser, 비번 : pwmyuser
create user 'myuser'@'localhost' identified by 'pwmyuser';

-- myuser에게 모든 권한 부여
grant all privileges on *.* to 'myuser'@'localhost';
-- mydb 생성
create database mydb;

-- 작업 전에 사용 db 실행
use mydb;

-- 테이블 생성
create table test(
	no	int,			-- 숫자자료형
    msg	varchar(100)	-- 문자자료형
);

insert into test values (1, '좋은 하루 되세요~');
insert into test values (2, 'Good luck!!');


commit;

select * from test;
use mydb;

-- news 테이블 생성
create table news (
	aid	        int primary key auto_increment,
	title       varchar(100) not null,
    content     text not null,
    create_date timestamp default now(),
    img	        varchar(40)
);

drop table news;

insert into news(title, content, img)  -- auto_increment : 일련번호, 시퀀스
values('경제 뉴스', '휘발유값이 너무 올랐습니다', 'car.jpg');
insert into news(title, content, img)
values('정치 뉴스', '이스라엘과 팔레스타인 전쟁', 'war.jpg');
insert into news(title, content, img)
values('스포츠 뉴스', '한국과 베트남 축구 성적 - 6:0', 'soccer.jpg');

-- 등록시간 순으로 정렬하시오
select *
from news
order by create_date desc;

-- 뉴스 내용중에 이스라엘이 포함된 뉴스를 검색하시오
select *
from news
where content like '%이스라엘%';

-- 뉴스 기사의 총 갯수
select count(title) 기사건수
from news;

commit;

select * from news;

 

-- 부서 사원 테이블 생성

use mydb;

create table department(
	deptid	int primary key,
    deptname	varchar(30) not null,
    location	varchar(20) not null
);

insert into department values (10, '개발팀', '서울');
insert into department values (20, '디자인팀', '부천');

select * from department;

commit;


create table employee(
	empid	int	primary key,
    empname	varchar(30) not null,
    age		int not null,
    sal		int,
    deptid	int not null,
    foreign key(deptid) references department(deptid)
);

insert into employee values (101, '한강', 27,2100000, 10);
insert into employee values (102, '백두산', 32,3200000, 20);
insert into employee values (103, '오과장',45 ,5500000, 10);
insert into employee values (104, '김대리', 38 ,4300000, 10);

select * from employee;

 

select * from department;
select * from employee;

-- 삽입 오류 체크 : 부서 테이블에 아이디가 30이 없어서 에러 
insert into employee values (106, '양신입', 25, null, 30);

-- 급여가 300만원 이상이고, 
select empid, empname
from employee
where sal >= 4000000 
  and deptid = 10;
  
-- 급여가 많은 순으로 정렬하시오
select *
from employee
order by sal desc;

-- 사원의 총인원, 급여 총액과 급여 평균을 구하시오
select count(*) as 총인원,
	   sum(sal) as 급여총액, 
	   round(avg(sal), -2) as 급여평균
from employee;

-- 부서별 급여 총액을 구하시오
select deptid as 부서번호, sum(sal) as 급여총액
from employee
group by deptid with rollup;

-- 부서이름을 포함한 사원의 모든 정보
select b.deptname 부서명, a.*
from employee as a, department as b
where a.deptid = b.deptid;
 
select b.deptname 부서명, a.*
from employee as a inner join department as b
  on a.deptid = b.deptid;
  
select b.deptname 부서명, a.*
from employee as a inner join department as b
  using (deptid);

-- 부서이름별 급여 총액
select deptid 부서번호, deptname 부서명, sum(sal) 급여총액, round(avg(sal), -2) 급여평균
from employee as a, department as b
where a.deptid = b.deptid
group by deptid, deptname with rollup;

select deptid 부서번호, deptname 부서명, sum(sal) 급여총액, round(avg(sal), -2) 급여평균
from employee as a inner join department as b
  on a.deptid = b.deptid
group by deptid, deptname with rollup;

select deptid 부서번호, deptname 부서명, sum(sal) 급여총액, round(avg(sal), -2) 급여평균
from employee as a inner join department as b
using(deptid)
group by deptid, deptname with rollup;

-- 최고 급여와 최저 급여를 받는 사원
select *
from employee
where sal = (select max(sal) from employee) 
   or sal = (select min(sal) from employee);
 
 -- 백두산 사원의 급여를 430만원으로 수정하세요
 update employee
 set sal = 4300000
 where empid = 102;  -- 기본키로만 변경이 가능함
 
 -- 사원의 급여 순위를 구하시오
 select empname 사원이름,
	    sal 급여,
        rank() over(order by sal desc) 급여순위1,
	    dense_rank() over(order by sal desc) 급여순위2
 from employee;

 

 

 

 

 

 

 

CSS 공부

<<디스플레이 특성>>
= 인라인, 블록, 인라인 블록

<인라인요소>
= 다른 요소들과 같은 라인에 배치
   모든 헤딩 요소 = 기본값이 블럭요소 => 스타일을 적용하면 요소가 알아서 길게 적용된걸 볼 수 있다
                                                     = 이런 경우 그 전체가 바디이다

<블럭요소>
= 다른 요소들을 다른 선으로 밀어낸다
   span요소 = 기본값이 인라인요소 => 줄 전체를 다 차지하지는 않는다
                                                 = 다른 요소나 내용을 다른 줄로 밀어내지 않음
  
* 디스플레이 특성으로 바꿔줄 수 있다
     = h1의 디스플레이를 인라인으로 설정 가능 -> display: inline;
                                                           => span과 똑같이 인라인 요소처럼 작동
     = span의 디스플레이를 블록으로 설정 가능 -> display: block;
                                                           => 헤딩요소와 같이 블락 요소처럼 작동
     => 인라인 블록 레벨 요소가
          여백, 패딩, 가로, 세로와 함께 기능한다

<인라인-블록>
= 인라인 요소처럼 작동하지만
   가로, 세로, 여백, 패딩이 제대로 적용된다
=> 공간을 공유하면서 같은 줄에 나란히 있고, 서로 다른 줄로 밀어내지 않는다
     하지만 박스 모델과 관련된 모든 특성은 잘 작동한다
     가로, 세로, 여백 모두 적용O

 

*CSS

span {
    background-color: palevioletred;
    border: 1px solid black;
    width: 500px;
    padding: 50px;
    margin: 50px;
}

h1 {
    background-color: paleturquoise;
    border: 1px solid black;
    width: 300px;
    padding: 50px;
    margin: 100px;
}

div {
    height: 200px;
    width: 200px;
    background-color: olivedrab;
    border: 5px solid black;
    display: inline-block;
    margin: 50px;
}

 

* HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="app5.css">
</head>
<body>

    <div></div>
    <div></div>
    <div></div>
    
    <h1>I am H1</h1>
    <h1>I am also H1</h1>
    <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. 
        Incidunt molestias quam similique tempora, odit numquam aut quasi quo dolore ea, velit est.
        Voluptate fuga quas, nobis voluptas eos nulla magnam?
        Lorem ipsum dolor sit amet consectetur, adipisicing elit. 
        Incidunt molestias quam similique tempora, odit numquam aut quasi quo dolore ea, velit est.
        Voluptate fuga quas, nobis voluptas eos nulla magnam?
        Lorem ipsum dolor sit amet consectetur, adipisicing elit. 
        <span>I AM SPAN!!!</span>
        Incidunt molestias quam similique tempora, odit numquam aut quasi quo dolore ea, velit est.
        Voluptate fuga quas, nobis voluptas eos nulla magnam?
        Lorem ipsum dolor sit amet consectetur, adipisicing elit. 
        Incidunt molestias quam similique tempora, odit numquam aut quasi quo dolore ea, velit est.
        Voluptate fuga quas, nobis voluptas eos nulla magnam?</p>
</body>
</html>

* 브라우저 페이지

 

 

 

 

 

** 슬슬 HTML, CSS, JavaScript를 이용해서

    할일 체크 목록을 만드는 작은 프로젝트를 한번 해볼까 고민중입니다

    이리저리 찾아보고 구상해봐서 

    저만의 작은 프로젝트가 성공적으로 완성되길 소망하고있습니다

 

 

 

 

2023. 10. 19 (목)

관련글 더보기