PlayData/MySQL

[Day 16 | MySQL] Table, Variable, ๋ฐ์ดํ„ฐ ๋ชจ๋ธ๋ง,

๊น€์œ ๋‹ˆ์ฝ˜ 2021. 12. 1. 08:59

p238 239

๋‚˜์ด์— int๋ฅผ ์ฃผ๋ฉด ๋‚ญ๋น„๋‹ค. int๋Š” ~21์–ต์—์„œ 21์–ต์ด๋‹ˆ๊นŒ.

๋ฐ์ดํ„ฐ ์‚ฌ์ด์ฆˆ์— ๋”ฐ๋ผ ๋งž์ถคํ˜•์œผ๋กœ ๋ฐ์ดํ„ฐํƒ€์ž…์„ ์ฃผ๋Š” ๊ฒƒ์ด ์ข‹๋‹ค. 

๋””์Šคํฌ์™€ ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„์ด ๋‚ญ๋น„๊ฐ€ ๋œ๋‹ค.

 

์‹ค์ œ๋กœ ๋””์Šคํฌ์— 4๋ฐ”์ดํŠธ๊ฐ€ ๋“ค์–ด๊ฐ€์žˆ๋‹ค๋ฉด, 

๋ฉ”๋ชจ๋ฆฌ์—๋„ ์ˆซ์ž 10์ด๋ผ๋„ 4๋ฐ”์ดํŠธ๊ฐ€ ์˜ฌ๋ผ๊ฐ„๋‹ค.  --> ๋‚ญ๋น„

 

๋ชจ๋ธ๋ง์ด๋‚˜ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ•  ๋•Œ๋Š” int ๋งŽ์ด ํ•˜์ง€๋งŒ, 

์„ฑ๋Šฅ๊นŒ์ง€ ๊ณ ๋ฏผํ•˜๋Š” ๋ฐ์ดํ„ฐ ์„ค๊ณ„๋Š” ๋ฐ์ดํ„ฐํƒ€์ž…์€ ์ ์ ˆํ•œ ๊ฒƒ์„ ๊ณ ๋ คํ•ด์„œ ํ•ด์•ผ.

 

PK์™€ not null unique์˜ ์ฐจ์ด๋Š”? 

๋ฐฑ๋‹จ์˜ ์ธ๋ฑ์Šค ๊ตฌ์กฐ๊ฐ€ ์กฐ๊ธˆ ๋‹ค๋ฆ„

PK๋Š” ํ…Œ์ด๋ธ” ๋‹น ๋ณดํ†ต ํ•˜๋‚˜ ๋งŒ๋“œ๋Š” ํ‚ค ์ œ์•ฝ์กฐ๊ฑด์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋จ 

 

 

 

-- --------------------
-- ํ…Œ์ด๋ธ” ์ƒ์„ฑ -- 

create table userTbl(
	uNo int auto_increment primary key, -- ์ œ์•ฝ ์กฐ๊ฑด์ด ๋“ค์–ด๊ฐ€๋ฉด 	
	uID varchar(10) not null unique,
	uName varchar(10) not null,
	uAge int not null check(uAge between 0 and 120), 
	uAddr char(4) default '์„œ',
	mob1 char(3) check(mob1 in ('010','011', '019')),
	mob2 char(8),
	uDate datetime not null default now()
);

๊ทธ๋Ÿผ ํ…Œ์ด๋ธ”์ด ์ƒ๊ธฐ์ž–์•„

์—ฌ๊ธฐ์„œ ์ œ์•ฝ ์กฐ๊ฑด ์ž˜ ๋“ค์–ด๊ฐ”๋Š”์ง€ ํ™•์ธ! 

๊ทธ๋Ÿฐ๋ฐ Name์ด ๋ญ”์ง€ ์•Œ ์ˆ˜ ์—†๋‹ค. 

 

 

๊ทธ๋ž˜์„œ 

์ด๋ ‡๊ฒŒ ์ œํ•œ ์กฐ๊ฑด๋“ค์„ ๋‹ค ๋”ฐ๋กœ ๋นผ์ฃผ์ž 

-- ์ด๋ฆ„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ํ…Œ์ด๋ธ” ๋งŒ๋“ค๊ธฐ -- 

create table userTbl(
	uNo int auto_increment , -- ์ œ์•ฝ ์กฐ๊ฑด์ด ๋“ค์–ด๊ฐ€๋ฉด 	
	uID varchar(10) not null,
	uName varchar(10) not null,
	uAge int not null , 
	uAddr char(4) default '์„œ์šธ',
	mob1 char(3) check(mob1 in ('010','011', '019')),
	mob2 char(8),
	uDate datetime not null default now(),

	
	CONSTRAINT userTb1_uNo_pk primary key(uNo),  -- ์ œ์•ฝ ์กฐ๊ฑด์„ ๋งŒ๋“ค์–ด๋ผ 
	CONSTRAINT userTb1_uID_uk UNIQUE KEY (uID),	
	constraint userTb1_uAge_ck check (uAge between 0 and 120),
	CONSTRAINT userTb1_uMob1_ck CHECK (mob1 in ('010', '011', '019'))
	
	
	);

 

 

 

 

 

์—”ํ‹ฐํ‹ฐ ๊ด€๊ณ„๋„

 

ํ…Œ์ด๋ธ” ๊ฐ„ ์—ฐ๊ฒฐ๊ณ ๋ฆฌ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

 

auto increment ๋ฅผ ์“ฐ๋ฉด (์ž๋™์œผ๋กœ ์ˆซ์ž ์ฆ๊ฐ€) ์—ฌ๊ธฐ์— ์ณŒ ํ‘œ์‹œ ๋˜์–ด์žˆ์Œ

auto increment  ์“ฐ๊ณ  ๋ฐ์ดํ„ฐ ์‚ฐ์ž…ํ–ˆ๋Š”๋ฐ ์—๋Ÿฌ๊ฐ€ ๋‚œ๋‹ค๋ฉด, 

์—๋Ÿฌ๋„ ์นด์šดํŒ…๋˜์–ด์„œ, 

๊ทธ ๋‹ค์Œ ๋ฐ์ดํ„ฐ insert ์‹œ์— ๋‹ค์Œ ๋„˜๋ฒ„๋กœ ๋„˜์–ด๊ฐ„๋‹ค. ์ด ๋•Œ๋Š” ๋‹ค๋ฅธ ์กฐ์น˜ ๋ฐฉ๋ฒ•์„ ์จ์ค˜์•ผ ํ•จ. 

 

-- > ํ•œ ์ˆ˜๊ฐ•์ƒ๋‹˜์˜ ๋‹ต๋ณ€ : mysql ์ด ๋‚ด๋ถ€์—์„œ inno DB ์—”์ง„์ผ๋•Œ auto increment๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ง‘๊ณ„๋˜์ง€ ์•Š์„ ๋•Œ๊ฐ€ ๊ฝค ๋งŽ์•„์š” ๊ทธ๋ž˜์„œ ๋ณดํ†ต auto_increment ๋ฅผ ๊ธฐ์กด ๊ฐ’์œผ๋กœ ์น˜ํ™˜ํ•˜๊ฑฐ๋‚˜, ๊ธฐ์กด ํ–‰์„ delete cascade๋กœ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค. (5v. ๊ธฐ์ค€) 

 

 

on delete cascade๋Š” ๊ฑฐ์˜ ์“ฐ์ง€ X

ํšŒ์› ํƒˆํ‡ดํ•ด๋„ ์•„์ด๋”” ์‚ญ์ œํ•˜์ง€ ๋ง๊ณ ,๋‚ด์—ญ์ด ๋‚จ์•„์•ผํ•˜๋‹ˆ๊นŒ, 

ON UPDATE cascade

 

 

Table01.sql

-- Table01.sql -- 
-- DDL : ์ •์˜ --> create, alter, drop -- 


CREATE TABLE  t30(
	id int, 
	age int not null check(age>0)  -- ์ปฌ๋Ÿผ ๋ฐ์ดํ„ฐํƒ€์ž… ์ œ์•ฝ์กฐ๊ฑด 
);

INSERT into t30 values(10, 10);
INSERT into t30 values(null, null);

SELECT * from t30;

create table t31(
	id int,
	age int not null, 
	check(age>0)
);

INSERT into t31 values(10, 10);
INSERT into t31 values(null, null);

SELECT * from t31;

show table status;


-- --------------------
-- ํ…Œ์ด๋ธ” ์ƒ์„ฑ -- 

create table userTbl(
	uNo int auto_increment primary key, -- ์ œ์•ฝ ์กฐ๊ฑด์ด ๋“ค์–ด๊ฐ€๋ฉด 	
	uID varchar(10) not null unique,
	uName varchar(10) not null,
	uAge int not null check(uAge between 0 and 120), 
	uAddr char(4) default '์„œ',
	mob1 char(3) check(mob1 in ('010','011', '019')),
	mob2 char(8),
	uDate datetime not null default now()
);

drop table userTbl ; 

-- --------------------------

-- ์ด๋ฆ„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ํ…Œ์ด๋ธ” ๋งŒ๋“ค๊ธฐ -- 

create table userTbl(
	uNo int auto_increment , -- ์ œ์•ฝ ์กฐ๊ฑด์ด ๋“ค์–ด๊ฐ€๋ฉด 	
	uID varchar(10) not null,
	uName varchar(10) not null,
	uAge int not null , 
	uAddr char(4) default '์„œ์šธ',
	mob1 char(3) check(mob1 in ('010','011', '019')),
	mob2 char(8),
	uDate datetime not null default now(),

	
	CONSTRAINT userTb1_uNo_pk primary key(uNo),  -- ์ œ์•ฝ ์กฐ๊ฑด์„ ๋งŒ๋“ค์–ด๋ผ 
	CONSTRAINT userTb1_uID_uk UNIQUE KEY (uID),	
	constraint userTb1_uAge_ck check (uAge between 0 and 120),
	CONSTRAINT userTb1_uMob1_ck CHECK (mob1 in ('010', '011', '019'))
	
	
	);

-- p331

drop table userTbl ;  

drop table buyTb1 ;  

-- buy table ๋งŒ๋“ค๊ธฐ 
create table buyTb1(
	bNo int  auto_increment , 
	bName varchar(20) not null, 
	price int not null, 
	amount int not null, 
	uNo int not null, 
	
	constraint buyTbl_bNo_pk primary key(bNo),
	constraint buyTbl_uNo_userTb1_fk foreign key userTbl(uNo)
			   references userTbl(uNo)
);


-- ---------------------


INSERT into userTbl values ( null, 'uTom', 'Tom', 30, default , '010', '11111111', default);

INSERT into buyTb1 values (null, 'Pen', 100, 3, 1);

SELECT * from buyTb1 bt ;

-- userTbl์˜ ๋ฐ์ดํ„ฐ ์‚ฝ์ž…์‹œ ์—๋Ÿฌ ํ™•์ธ 
INSERT into userTbl values ('uJane', 'Jane', 30, default , '010', '11111111', default); -- ๋ฐ์ดํ„ฐ ๊ฐœ์ˆ˜ ์•ˆ๋งž์•„์„œ ์•ˆ๋จ
INSERT into userTbl values (null, 'uTom', 'Jane', 30, default , '010', '11111111', default); -- ์ œ์•ฝ์กฐ๊ฑด์— ์–ด๊ธ‹๋‚˜์„œ X
INSERT into userTbl values (null, 'uJane', null , 30, default , '010', '11111111', default); -- ์ œ์•ฝ์กฐ๊ฑด์— ์–ด๊ธ‹๋‚˜์„œ X
INSERT into userTbl values (null, 'uJane', null , 2000, default , '010', '11111111', default); -- ๋‚˜์ด ์ œ์•ฝ์กฐ๊ฑด์— ์–ด๊ธ‹๋‚˜์„œ X



-- buyTbl์˜ ๋ฐ์ดํ„ฐ ์‚ฝ์ž…์‹œ ์—๋Ÿฌ ํ™•์ธ
INSERT into buyTb1 values ( 'Pen', 100, 3, 1); --  Column count doesn't match value count at row 1
INSERT into buyTb1 values (null, 'Pen', 100, 3, 2); -- CONSTRAINT `buyTbl_uNo_userTb1_fk` FOREIGN KEY (`uNo`) REFERENCES `usertbl` (`uNo`))
INSERT into buyTb1 values (null, NULL , 100, 3, 1); -- Column 'bName' cannot be null
INSERT into buyTb1 values (1 , 'Pen', 100, 3, 1); -- Duplicate entry '1' for key 'buytb1.PRIMARY'



------------------------------------------

-- p328

-- ํ…Œ์ด๋ธ” ์ƒ์„ฑ ์ดํ›„์— ์ œ์•ฝ ์กฐ๊ฑด์„ ์ถ”ํ›„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค. 

create table uTbl(
	uNo int not null,
	uID varchar(10) not null,
	uName varchar(10) not null,
	uAge int not null ,
	uAddr char(4) ,
	mob1 char(3) ,
	mob2 char(8),
	uDate datetime not null 
);


-- ์ œ์•ฝ์กฐ๊ฑด ์—†๋˜๊ฑธ ๋งŒ๋“œ๋Š” 
ALTER table uTbl 
 ADD CONSTRAINT uTbl_uNo_pk primary key(uNo);


-- ๋””ํดํŠธ๊ฐ’ ์ œ์•ฝ์กฐ๊ฑด ์ˆ˜์ •  
ALTER table uTbl 
 alter column uAddr set DEFAULT 'SEOUL'; -- ์ปฌ๋Ÿผ ๋ณ€๊ฒฝ 
 

 
 ALTER table uTbl 
  add column height smallint; -- ์ปฌ๋Ÿผ ์ถ”๊ฐ€ p336 
 
  
ALTER table uTbl 
 add column weight smallint; -- ์ปฌ๋Ÿผ ์ถ”๊ฐ€ 
 
  
ALTER table uTbl 
 add column height; -- ์ปฌ๋Ÿผ ์ œ๊ฑฐ

\

 

 

 

 

SQL๋„ ์ปดํŒŒ์ผ ์–ธ์–ด์ด๊ธฐ ๋•Œ๋ฌธ์—, ๋ณ€์ˆ˜ ์‚ฌ์šฉ ๊ฐ€๋Šฅ

๋ชฉ์ : ๊ฒฐ๊ณผ ์ฒ˜๋ฆฌ 

--------------- J a v a --------------

๋ณ€์ˆ˜

์—ฐ์‚ฐ์ž(์‚ฐ์ˆ , ์—ฐ๊ฒฐ, ๋…ผ๋ฆฌ, ๋น„๊ต,,,)

์กฐ๊ฑด๋ฌธ(if else) 

๋ฐ˜๋ณต๋ฌธ (for ,,)

์˜ˆ์™ธ์ฒ˜๋ฆฌ (try catch)

ํ•จ์ˆ˜(๋ธ”๋ก) --> function

 

------------------------------------

 

 

--> ์ด๋Ÿฐ ๊ฒƒ๋“ค์„ ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด Stored Procedure ๋ผ๋Š” DB ๊ฐ์ฒด 

p439

๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ž˜ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋„˜์–ด์•ผ ํ•  ์š”์†Œ: Stored Procedure (๋ง›๋ณด๊ธฐ๋งŒ ํ•œ๋‹ค) 

^์„ฑ๋Šฅ์ด ์ข‹์Œ 

 

 

Variable01.sql

-- Variable01 -- 

-- JAVA์—์„œ๋Š” 
int i = 10; 
SYSTEM. OUT.println(i);


-- p244
SET @i = 10; 
SELECT @i;

SET @j = 20; 
SELECT @i + @j;

set @iSal = 3000; 

SELECT * 
from emp
where sal > @isal; 

set @iSal = 2500;
prepare eQuery  -- ๊ตฌ๋ฌธ์„ ๋ฏธ๋ฆฌ ์ค€๋น„ 
	from 'select * from emp where sal > ?'; -- ์ด ์ฟผ๋ฆฌ์— ๋„ฃ์–ด๋ผ 
execute eQuery using @iSal; -- ์‹คํ–‰์‹œํ‚ค๋Š”๋ฐ, ?์— ๋Œ€ํ•œ ๊ฐ’์„ @iSal๋ณ€์ˆ˜์—์„œ ๋ฐ›์•„๊ฐ€๋ผ

delimiter $$ 
create procedure usp_emp1()
begin
 select * from emp;
end $$;

delimeter; 


call usp_emp1();

-----------
-- --------------------------
delimiter $$ 
create procedure usp_emp2(in iSal int)
begin
 select * from emp where sal > iSal;
end $$

-- call usp_emp2();
call usp_emp2(2500);
call usp_emp2(2999);

-- ํ•œ ๋ฒˆ ๋“ฃ๊ณ  ํ˜๋ ค๋„ ๋ฉ๋‹ˆ๋‹ค. ๋‚˜์ค‘์— ๊ณต๋ถ€ํ• ๋•Œ, ์•Œ์•„๋‘๋ฉด ์ข‹์Œ

 

์ด๊ฒŒ ์ •์„

1. UI?

2. CLIENT?

3. DB?

4. DB ๋ชจ๋ธ๋ง?

5. stored procedure 

 

๊ทผ๋ฐ ์ธ๋ ฅ์ด ๋”ธ๋ฆฌ๋‹ˆ๊นŒ 5๋ฒˆ ๋บŒ 

 

 

 

 

 

java sql์„ html๋กœ ๊ฐ์‹ผ๋‹ค --> ์ด๊ฒŒ JSP

java 

 

์Šคํ”„๋ง์ด๋ผ๋Š” ํ”„๋ ˆ์ž„์›Œํฌ

์กฐ๊ธˆ ๋” ๋‚˜์•„๊ฐ€์„œ 

5. stored procedure ๋“ฑ๋“ฑ db์ปดํฌ๋„ŒํŠธ๋“ค์„ ๊ฐœ๋ฐœํ•˜๊ณ  ์‹ถ๋‹ค? 

๊ทธ๋Ÿผ sp , view๋ฅผ ๊ฐ€์ง€๊ณ  ํ•˜๋ฉด ๋œ๋‹ค. 

1,2,3,4,5 ๋‹ค ํ• ๊ฑฐ๋ƒ์˜ ์„ ํƒ์€ ์ธ๋ ฅ์— ๋”ฐ๋ผ ์„ ํƒ \

 

 

 

ํ…Œ์ด๋ธ” ๊ตฌ์„ฑํ•˜๋Š” ๊ฒƒ 

ํ…Œ์ด๋ธ” ๊ตฌ์„ฑ๋„๋ฅผ ๋งŒ๋“ ๋‹ค. 

erd

๋ชจ๋ธ๋ง ๋„๊ตฌ๋“ค์€ ์œ ๋Ÿฝ ๋„๊ตฌ๊ฐ€ ๋งŽ์Œ 

 

 

 

 

์›น:

 

1. ํ”„๋กœ์ ํŠธ ์„ค๊ณ„ ๊ธฐ๋ณธ ํ๋ฆ„(ํ”„๋กœ์ ํŠธ ๊ตฌ์ถ•) 

2. html ๊ตฌ์„ฑ์ •๋ณด๋กœ ์–ด๋–ค ๋ฐ์ดํ„ฐ๋ฅผ ๋ฝ‘์„ ์ˆ˜ ์žˆ๋Š”์ง€ ๋ฐ์ดํ„ฐ ๊ทผ์›์ง€ ์•Œ ์ˆ˜ ์žˆ์Œ. (ํ•˜๋‘ก์— ์ €์žฅ, ์ €์žฅ ์‹œ์Šคํ…œ์— ๋Œ€ํ•œ ์ดํ•ด) 

3. ํŒŒ์ด์ฌ ๋ถ„์„. (์‹ค์ œ ์ €์žฅ๋œ ๋‚ด์šฉ ๋ถ„์„) 

 

ํŒŒ์ด์ฌ ๋ถ„์„์„ ์ž˜ ํ•˜๋”๋ผ๋„, ํ”„๋กœ์ ํŠธ ๊ธฐ์Šน์ „๊ฒฐ ์•Œ๊ธฐ๊ฐ€ ํž˜๋“ค์–ด์š”. 

1. ๋ชฉ์ ์ด ๋ถ„๋ช…ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Œ.

 

๋ฐฉํ–ฅ ์žก๊ธฐ ๋ฐ์ดํ„ฐ ๋ถ„์„ ๊ด€๋ จ 

1. ํŒŒ์ด์ฌ + ๋ถ„์„ ์–น๊ธฐ(Code mind, ๋ญ˜ ํ•ด์•ผํ• ์ง€๋ฅผ ๋ชจ๋ฅด๊ฒŒ ๋จ) 

2. ํ†ต๊ณ„ ๋ถ„์„ ์ฑ…์ธ๋ฐ ํŒŒ์ด์ฌ ์–ธ์–ด ์—†์Œ(Business mind, ๋‚˜ ํŒŒ์ด์ฌ์„ ๋ฐฐ์› ๋Š”๋ฐ ์™œ ๋ชป๋‹ค๋ฃจ์ง€?)

3. ์œตํ•ฉํ•˜๋ ค๋‹ค๋ณด๋ฉด, ๋ชจ๋“ ๊ฑธ ๋‹ค ๋‹ด์œผ๋ คํ•ด์„œ ์–ด๋ ค์›€. 

 

ํ•œ๊ตญ์—์„œ๋Š” DB --> big data๋กœ ํ˜๋Ÿฌ๊ฐ. 

์ฒ˜์Œ ๋น…๋ฐ์ดํ„ฐ ๊ณผ์ •์ด ๊ทธ๋ž˜์„œ ํ•˜๋‘ก์œผ๋กœ ๋งŒ๋“ค์–ด์ง. 

์˜๋ฌธ: ์ €์žฅ๊ธฐ์ˆ ์— ๋ฌด์Šจ ๋น…๋ฐ์ดํ„ฐ ๋ถ„์„์ด ๋“ค์–ด๊ฐ€? 

 

๋น…๋ฐ์ดํ„ฐ๋Š” ์›น, ํšŒ์‚ฌ๋‚ดdb, ์ผ๋ฐ˜ ํŒŒ์ผ, ์‹œ์Šคํ…œ ๋กœ๊ทธ ๋“ฑ ์—์„œ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋‹ค. 

๊ทธ๋Ÿฌ๋‚˜ ์ผ๋ฐ˜์ ์œผ๋กœ ์›น์œผ๋กœ ์ƒ๊ฐํ•จ. Big Data (volume, variety, velocity) --> ๊ทธ๋ž˜์„œ ์›น์ผ ์ˆ˜ ๋ฐ–์— ์—†์Œ. 

 

๋ฐ์ดํ„ฐ์˜ ๋ชฉ์ ์ด ์–ด๋””์žˆ๋Š๋ƒ? 

์‹œ๋‚˜๋ฆฌ์˜ค๋กœ ๊ธฐ์Šน์ „๊ฒฐ์„ ๋งŒ๋“ค์–ด๊ฐ€์•ผํ•˜๋Š”๋ฐ, ์–ด? ํ†ต๊ณ„, ์ˆ˜ํ•™ --> ์‹œ๊ฐํ™” ํ•„์š”ํ•˜๋„ค? 

๋น…๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ ์–ด๋–ป๊ฒŒ ํ•˜๋‚˜ ? --> ์—‘์…€, ํƒ€๋ธ”๋กœ (์œ ์—ฐํ•˜์ง€ ์•Š์•„)

-- > ์–ธ์–ด์ ์ธ ์ฒ˜๋ฆฌ ํ•ด๋ณด์ž (ํŒŒ์ด์ฌ)

 

๋ฐ์ดํ„ฐ ์–‘์ด ๋งŽ๋„ค? ์ €์žฅ๊ธฐ์ˆ  ํ•„์š”ํ•˜๋„ค (ํ•˜๋‘ก

์›น์„ ์ดํ•ดํ•ด๋ณด์ž --> ๊ทธ๋Ÿผ ๊ตฌ์ถ•ํ•ด๋ณด์ž 

์›น์„œ๋ฒ„ ๊ตฌ์ถ•ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”? --> ๊ฒŒ์‹œํŒ ๋งŒ๋“ค์–ด๋ณด๋ž˜. --> 3. db ํ…Œ์ด๋ธ” ํ•„์š”ํ•˜๋„ค, 2. ์ฒ˜๋ฆฌํ•˜๋ ค๋ฉด ์ž๋ฐ” ํ•„์š”ํ•˜๊ณ , 1. ์ด๊ฑธ UI๋กœ ๋งŒ๋“ค์–ด์ค˜์•ผ์ง€ 

์›น ํฌ๋กค๋ง์˜ ๊ธฐ๋ณธ ๊ธฐ์ˆ ์„ html, css, javascript ์–ด๋””์„œ ์ฝ์–ด์˜ฌ๋ž˜? --> UI๋ฅผ ํ•ด์•ผ๊ฒ ๋‹ค. 

 

 

๋ฐ์ดํ„ฐ ๋ชจ๋ธ๋ง

- ๊ด€๊ณ„ํ˜• DB< 

 

๋ฐ์ดํ„ฐ ๋ชจ๋ธ๋ง ๊ณผ์ •: 

1.  ํ˜„์‹ค(์—…๋ฌด ํ”„๋กœ์„ธ์Šค) ์ดํ•ด <-- ๊ณ ๊ฐ ๋‹ˆ์ฆˆ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฒ”์œ„ ์ œํ•œ --> ๋ช…์„ธ (๋ฌธ์„œ๋กœ ๋‚จ๊น€) 

ํ˜„์‹ค(์—…๋ฌด ํ”„๋กœ์„ธ์Šค) ์ดํ•ด

2.  ๊ฐœ๋…์  ๋ชจ๋ธ๋ง --> ๊ฐœ๋…์  ๊ตฌ์กฐ

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ERD(Entity Relationship Diagram)&nbsp;

          --> ERD(Entity Relationship Diagram) 

 

3.  ๋…ผ๋ฆฌ์  ๋ชจ๋ธ๋ง --> ๋…ผ๋ฆฌ์  ๊ตฌ์กฐ(Data ๋ชจ๋ธ) 

 

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ์ •๊ทœํ™”&nbsp;

     - ํ•™๋ฒˆ / ๊ณผ๋ชฉ ์ฝ”๋“œ : ํ‚ค๊ฐ’.

          --> ์ •๊ทœํ™” 

 

4.  ๋ฌผ๋ฆฌ์  ๋ชจ๋ธ๋ง --> ๋ฌผ๋ฆฌ์  ๊ตฌ์กฐ 

          --> ์ •๊ทœํ™” RDBMS ์„ ์ •, ํ…Œ์ด๋ธ” ํ™” ํ• ์ˆ˜์žˆ๋Š” ๋ฐ์ดํ„ฐ ํƒ€์ž…, ์‚ฌ์ด์ฆˆ ์ •์˜ 

 

 

---------------------------------------------------------------------------------------------------

 

 

 

--------

 

๋„์„œ ๋Œ€์—ฌ์ ์˜ ์ฃผ ๋ฐ์ดํ„ฐ: ๋„์„œ 

 

 

์•„๋ž˜์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ํ…Œ์ด๋ธ”์„ ๋งŒ๋“ฌ 

์ฝ์–ด๋ณด๊ธฐ: https://travislife.tistory.com/13

https://hyonee.tistory.com/117

 

๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ชจ๋ธ๋ง

01. ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค ๋ชจ๋ธ๋ง ์š”๊ตฌ์กฐ๊ฑด๋ถ„์„  -- ๊ฐœ๋…์  ์„ค๊ณ„ -- ๋…ผ๋ฆฌ์  ์„ค๊ณ„ -- ๋ฌผ๋ฆฌ์  ์„ค๊ณ„ -- ๊ตฌํ˜„  (์š”๊ตฌ์‚ฌํ•ญ๋ช…์„ธ์„œ) -- (ERD)  --  (ERD ๊ด€๊ณ„ ์ •๋ฆฝ) 02. ์š”๊ตฌ์กฐ๊ฑด๋ถ„์„ : ์‚ฌ์šฉ์ž๊ฐ€ ์›ํ•˜๋Š” ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค

hyonee.tistory.com

 

[๋ฐ์ดํ„ฐ๋ชจ๋ธ๋ง] ๋ฐ์ดํ„ฐ๋ชจ๋ธ๋ง ์ดํ•ด (๋‹จ๊ณ„, ERD, ์ •๊ทœํ™”)

[๋ฐ์ดํ„ฐ ๋ชจ๋ธ๋ง] ๋ฐ์ดํ„ฐ๋ชจ๋ธ๋ง ์ดํ•ด (๋‹จ๊ณ„, ER ๋‹ค์ด์–ด๊ทธ๋žจ, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ •๊ทœํ™”) ๋ฐ์ดํ„ฐ๋ชจ๋ธ๋ง์˜ ๋‹จ๊ณ„์™€, ERD ๋‹ค์ด์–ด๊ทธ๋žจ, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ •๊ทœํ™”์— ๋Œ€ํ•œ ๋‚ด์šฉ์„ ๊ตฌ๋ถ„ํ•˜์—ฌ ์•Œ์•„๋ณด๊ณ ์ž ํ•œ๋‹ค. ๋ฐ์ดํ„ฐ

travislife.tistory.com

๋ฐ์ดํ„ฐ ๋ชจ๋ธ๋ง์€ ํ˜„์‹ค์„ธ๊ณ„ ์—…๋ฌด์—์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šคํ™” ํ•˜๊ธฐ ์œ„ํ•œ ๊ณผ์ •

 

 

 

 

ํ…Œ์ด๋ธ”์„ createํ•  ์ˆ˜๋„ ์žˆ์ง€๋งŒ ์›Œํฌ๋ฒค์น˜์—์„œ ๋ฐ”๋กœ ๋„ฃ์„ ์ˆ˜ ์žˆ์Œ.

ERD ๋‹ค ๋งŒ๋“  ์ƒํƒœ์—์„œ ๊ทธ๋ฆฌ๋Š” ๊ฒƒ . 

 

 

์ด๋ ‡๊ฒŒ FK๋„ ๋ฐ”๋กœ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Œ! 

 

 

 

 

 

 


๊ณผ์ œ:

1. ์–ด์ œ ์ž‘์„ฑํ•œ ํ…Œ์ด๋ธ” ์„ค๊ณ„๋„๋ฅผ 

ํšŒ์› ํ…Œ์ด๋ธ”, ๊ฒŒ์‹œํŒ ํ…Œ์ด๋ธ”

 

- ๊ฐœ๋…์  ๋ชจ๋ธ๋ง : ERD ์ž‘์„ฑ์„ ํ•˜๊ณ , 

- ๋…ผ๋ฆฌ์  / ๋ฌผ๋ฆฌ์  ๋ชจ๋ธ๋ง Table ํ™” 

- DDL์™„์„ฑ 

 

2. Shop DB ๋งŒ๋“ค์–ด๋ณด๊ธฐ 

- Entitiy: [ ํšŒ์› ] -  < ๊ตฌ๋งค > -  [ ์ƒํ’ˆ ] 

- ๋…ผ๋ฆฌ์  / ๋ฌผ๋ฆฌ์  ๋ชจ๋ธ๋ง Table ํ™”

- DDL์™„์„ฑ