글과 인물의 관계망 (김선미)

DH 교육용 위키
이동: 둘러보기, 검색

네트워크 데이터 시각화 예시

1촌 관계망


2촌 관계망


검색


데이터 변환 스크립트

  • 현재의 파일은 '문집' 데이터의 id와 내용이 전혀 안맞는 것 같으니 확인할 것.
use azuremei

select * from sys.tables

/* 데이터 작업 소스 파일 */
select * from nodes_Document
select * from nodes_Book
select * from Links_P_D2

/* 최종 산출물 */
drop table bioData
drop table bioLinks

create table bioData(
	id	nvarchar(40) not Null,
	class nvarchar(20) NULL,
	groupName nvarchar(20) NULL,
	partName nvarchar(20) NULL,
	label nvarchar(80) NULL,
	hanja nvarchar(80) NULL,
	infoUrl nvarchar(256) NULL,
	iconUrl nvarchar(256) NULL,
	note	nvarchar(80) NULL
	primary key(id)
)

create table bioLinks (
	source nvarchar(40) not NULL,
	target nvarchar(40) not NULL,
	relation nvarchar(40) not NULL,
	attribute nvarchar(40) NULL
	primary key (source, target, relation )
)

/* 작업 파일 */
drop table docLinks
drop table unique_id

create table docLinks (
	source nvarchar(40) not NULL,
	target nvarchar(40) not NULL,
	relation nvarchar(40) not NULL,
	attribute nvarchar(40) NULL
)

/* Node List: bioData 생성 */

--1. bioData에 문집 데이터 추가

insert into bioData( id, class, groupName, partName, label, hanja, infoUrl, iconUrl, note)
select rtrim(ID), '문집', NULL, NULL, rtrim(문집명_한글)+' '+rtrim(문집명)+' / '+rtrim(간행년), rtrim(문집명), NULL, NULL, rtrim(총간집수)
from nodes_Book

--2. bioData에 글 데이터 추가

select  고전종합ID as id, count(*) as counts
into unique_id
from nodes_Document
group by 고전종합ID having count(*)=1

insert into bioData( id, class, groupName, partName, label, hanja, infoUrl, iconUrl, note)
select 고전종합ID, '글', 문체, NULL, 편목명, 편목명, NULL, NULL, 위치정보
from nodes_Document
join unique_id on nodes_Document.고전종합ID= unique_id.id
where len(편목명) < 80

--3. bioData에 인물 데이터 추가

insert into bioData( id, class, groupName, partName, label, hanja, infoUrl, iconUrl, note)
select distinct TIkcd_id, '인물', NULL, NULL, F2, F2, NULL, NULL, NULL from Links_P_D2
where TIkcd_id is not Null


/* Link List: bioLinks 생성 */

--1. bioLinks에 글과 인물의 관계 추가

delete docLinks -- temporary work space

insert into docLinks
select 고전종합ID, TIKCD_ID, F4, NULL from Links_P_D2
where TIKCD_ID is not NULL and F4 is not NULL

insert into bioLinks
select distinct source, target, relation, attribute from docLinks
join bioData as a on source=a.id
join bioData as b on target=b.id

update bioLinks
set relation='creator'
where relation='hasCreator'

--2. bioLinks에 문집과 글의 관계 추가

delete docLinks -- temporary work space

insert into docLinks
select distinct substring(id, 1, 12), id, 'hasPart', NULL from bioData
where class='글'

insert into bioLinks
select distinct source, target, relation, attribute from docLinks
join bioData on source=id

/* 추가 작업 예시 */

--1. 여인 식별

update bioData
set groupName='여성'
where class='인물' and hanja like '%妻%'

--2. bioLinks에 부부 관계 추가

create table 부부 (
	남편 nvarchar(20) NULL,
	아내 nvarchar(20) NULL
)

insert into 부부 values 
	( N'康奎煥', N'康奎煥妻文氏'),
	( N'姜大遂', N'姜大遂妻李氏'),
	( N'姜德後', N'姜德後妻柳氏'),
	( N'姜櫓', N'姜櫓妻李氏'),
	( N'姜履德', N'姜履德妻李氏'),
	( N'姜履一', N'姜履一妻任氏'),
	( N'姜命奎', N'姜命奎妻金氏'),
	( N'姜某', N'姜某妻張氏'),
	( N'姜文奎', N'姜文奎1妻金氏'),
	( N'姜昺奎', N'姜昺奎妻崔氏'),
	( N'姜鳳翎', N'姜鳳翎妻文氏'),
	( N'姜世晉', N'姜世晉妻李氏'),
	( N'姜世晃', N'姜世晃妻柳氏'),
	( N'姜純一', N'姜純一妻李氏'),
	( N'姜時周', N'姜時周妻許氏'),
	( N'姜植', N'姜植妻李氏'),
	( N'姜儼', N'姜儼妻柳氏'),
	( N'姜楧', N'姜楧妻李氏'),
	( N'姜遇慶', N'姜遇慶妻李氏'),
	( N'姜鄅', N'姜鄅妻李氏'),
	( N'姜運奎', N'姜運奎妻高氏'),
	( N'姜橒', N'姜橒妻李氏'),
	( N'姜渭輔', N'姜渭輔妻吳氏'),
	( N'姜應周', N'姜應周妻金氏'),
	( N'姜彝大', N'姜彝大妻趙氏'),
	( N'姜日會', N'姜日會妻柳氏'),
	( N'姜在洙', N'姜在洙妻權氏'),
	( N'姜柱龍', N'姜柱龍妻鄭氏'),
	( N'姜焌馨', N'姜焌馨妻金氏'),
	( N'姜㮨', N'姜㮨妻金氏'),
	( N'姜晉奎', N'姜晉奎妻李氏'),
	( N'姜酇', N'姜酇妻權氏'),
	( N'姜必敬', N'姜必敬妻權氏'),
	( N'姜必魯', N'姜必魯妻柳氏'),
	( N'姜必輔', N'姜必輔妻鄭氏'),
	( N'姜必愼', N'姜必愼妻睦氏'),
	( N'姜必臣', N'姜必臣妻安氏'),
	( N'姜必孝', N'姜必孝妻金氏'),
	( N'姜漢奎', N'姜漢奎妻李氏'),
	( N'姜獻奎', N'姜獻奎妻李氏'),
	( N'姜顯周', N'姜顯周妻鄭氏'),
	( N'姜綊', N'姜綊妻李氏'),
	( N'康灝', N'康灝妻申氏'),
	( N'姜鎤', N'姜鎤妻李氏'),
	( N'姜會奎', N'姜會奎妻權氏'),
	( N'姜會奎', N'姜會奎妻李氏'),
	( N'姜希孟', N'姜希孟妻安氏'),
	( N'姜𣽤', N'姜𣽤妻洪氏'),
	( N'姜𨪌', N'姜𨪌妻李氏'),
	( N'姜𨬔', N'姜𨬔妻柳氏'),
	( N'慶綿', N'慶綿妻張氏'),
	( N'高儉', N'高儉妻權氏'),
	( N'高光旭', N'高光旭妻申氏'),
	( N'高克台', N'高克台妻崔氏'),
	( N'高尙顏', N'高尙顏妻朴氏'),
	( N'高省久', N'高省久妻姜氏'),
	( N'高成鎭', N'高成鎭妻林氏'),
	( N'高世鎭', N'高世鎭妻申氏'),
	( N'高瀟', N'高瀟妻鄭氏'),
	( N'高燁', N'高燁妻李氏'),
	( N'高殷相', N'高殷相妻李氏'),
	( N'龔鼎孶', N'龔鼎孶妻童氏'),
	( N'孔宗履', N'孔宗履妻姜氏'),
	( N'郭景默', N'郭景默妻金氏'),
	( N'郭繼儀', N'郭繼儀妻李氏'),
	( N'郭林夏', N'郭林夏妻柳氏'),
	( N'郭源兆', N'郭源兆妻鄭氏'),
	( N'郭再祺', N'郭再祺妻李氏'),
	( N'郭海', N'郭海妻張氏'),
	( N'郭懷英', N'郭懷英妻河氏'),
	( N'喬可聘', N'喬可聘妻潘氏'),
	( N'具思謇', N'具思謇妻鄭氏'),
	( N'具壽永', N'具壽永妻李氏'),
	( N'具淳', N'具淳妻李氏'),
	( N'具長孫', N'具長孫妻盧氏'),
	( N'具昌晳', N'具昌晳妻崔氏'),
	( N'具致用', N'具致用妻金氏'),
	( N'具洽', N'具洽妻申氏'),
	( N'權景祐', N'權景祐妻魚氏'),
	( N'權啓夏', N'權啓夏妻李氏'),
	( N'權耈', N'權耈1妻金氏'),
	( N'權耈', N'權耈2妻李氏'),
	( N'權克義', N'權克義1妻盧氏'),
	( N'權達手', N'權達手妻鄭氏'),
	( N'權德容', N'權德容妻金氏'),
	( N'權斗紘', N'權斗紘妻趙氏')

select 남편, a.id, 아내,b.id from 부부
join bioData as a on 남편=a.hanja
join bioData as b on 아내=b.hanja

insert into bioLinks
select a.id, b.id, 'hasWife', NULL from 부부
join bioData as a on 남편=a.hanja
join bioData as b on 아내=b.hanja

/* Icon 지정 */

--문집

update bioData
set iconUrl='http://dh.aks.ac.kr/Encyves/Graph/icons/text2.png'
where class='문집'

--글

update bioData
set iconUrl='http://dh.aks.ac.kr/Encyves/Graph/icons/letter.png'
where class='글'

--남자

update bioData
set iconUrl='http://dh.aks.ac.kr/Encyves/Graph/icons/joseon_yangban_mid.png'
where class='인물' and groupName is NULL

--여자

update bioData
set iconUrl='http://dh.aks.ac.kr/Encyves/Graph/icons/joseon_female_mid_etc.png'
where class='인물' and groupName='여성'