以mysql为例的数据字典_建立数据字典
本例以 MySQL 數(shù)據(jù)庫(kù)為例。
2.1 連接 FineDB 數(shù)據(jù)庫(kù)
2.1.1 為 FineBI 設(shè)置外接數(shù)據(jù)庫(kù)
1)新建「finedb」數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù)名必須為「finedb」,設(shè)置默認(rèn)字符集排序規(guī)則為 utf_bin( mysql 數(shù)據(jù)庫(kù)需要設(shè)置排序規(guī)則為 utf8_bin),如下圖所示:
2) FineBI 連接外接數(shù)據(jù)庫(kù),如下圖所示:
3)在 FineBI 中新建數(shù)據(jù)連接,連接到外接數(shù)據(jù)庫(kù),測(cè)試連接成功,點(diǎn)擊保存,如下圖所示:
詳情參見(jiàn):配置數(shù)據(jù)連接 。
4)在數(shù)據(jù)準(zhǔn)備界面可查看數(shù)據(jù)庫(kù)以及數(shù)據(jù)庫(kù)表,如下圖所示:
5)在外接數(shù)據(jù)庫(kù)中新建「fine_data_dictionary」數(shù)據(jù)庫(kù)表,表字段、類型、注釋如下圖所示:
注:這張表是數(shù)據(jù)字典維護(hù)表, IT 和業(yè)務(wù)維護(hù)的數(shù)據(jù)字典會(huì)存入這張表中。其中業(yè)務(wù)包名、表名、字段名是必須的,其余字段可以修改,按實(shí)際使用增加,填報(bào)時(shí)拉入字段即可。
2.1.2 獲取相關(guān)數(shù)據(jù)
1)添加?SQL 數(shù)據(jù)集,獲取 BI 中所有表原始信息。
輸入 SQL 語(yǔ)句如下所示:select MID(A.id,32,16) as tableId ,A.VALUE as origName,A.T_ID, REPLACE( REPLACE(B.className,'com.finebi.common.internalimp.config.conf.entryinfo.',' ') , 'EntryInfoConf',' ' ) as tableType from
(
SELECT
REPLACE(id,".name","") as id, `value` , UCASE( CONCAT("T_",mid(id,32,6)) ) as T_ID
FROM
fine_conf_entity
WHERE ID IN
(
SELECT
CONCAT(id,'.name') as nameId
from
fine_conf_classname
where
id like 'DirectEntryConfStore.mapHolder.________________' and #對(duì)應(yīng)配置表名
className like 'com.finebi.common.internalimp.config%' #數(shù)據(jù)表過(guò)濾
)
) as A
left join
fine_conf_classname as B
on A.id = B.id
得到 BI 數(shù)據(jù)原始信息如下圖所示:
2)添加?SQL 數(shù)據(jù)集,獲取 BI 數(shù)據(jù)表顯示名。
SQL 語(yǔ)句如下所示:
SELECT mid(AA.id,32,16) as tableId ,AA.`value` AS tableName
from
fine_conf_entity AA
where
AA.id like 'DirectEntryConfStore.mapHolder.%.escapeMap.________________'
得到 BI 數(shù)據(jù)顯示名如下圖所示:
3)添加?SQL 數(shù)據(jù)集,獲取 BI 所有業(yè)務(wù)包信息。
SQL 語(yǔ)句如下所示:
SELECT CC.tableId,CC.PackId, DD.`value` as PackName
from
fine_conf_entity DD ,
(
SELECT REPLACE(AA.id,"tableIds","name") as PackId , BB.tableId as tableId
from fine_conf_entity AA ,
(select MID(A.id,32,16) as tableId ,A.VALUE as origName,A.T_ID, REPLACE( REPLACE(B.className,'com.finebi.common.internalimp.config.conf.entryinfo.',' ') , 'EntryInfoConf',' ' ) as tableType from
(
SELECT
REPLACE(id,".name","") as id, `value` , UCASE( CONCAT("T_",mid(id,32,6)) ) as T_ID
FROM
fine_conf_entity
WHERE ID IN
(
SELECT
CONCAT(id,'.name') as nameId
from
fine_conf_classname
where
id like 'DirectEntryConfStore.mapHolder.________________' and #對(duì)應(yīng)配置表名
className like 'com.finebi.common.internalimp.config%' #數(shù)據(jù)表過(guò)濾
)
) as A
left join
fine_conf_classname as B
on A.id = B.id
) as BB
where
AA.id like 'DirectPackageConfStore%' and LOCATE(BB.tableId,AA.`value`) > 0
) as CC
where DD.id = CC.PackId
得到 BI 數(shù)據(jù)業(yè)務(wù)包信息如下圖所示:
4)添加?SQL 數(shù)據(jù)集,獲取 BI 數(shù)據(jù)表字段信息。
SQL 語(yǔ)句如下所示:
SELECT A.*,C.fieldnam? from (select id,substring_index((substring(id,32)),'.',1) as tableID,mid(id ,56,8) as scrname ,value as
filename? from? fine_conf_entity? where id like '%DirectFieldConfStore.mapHolder%name') as A
LEFT JOIN
(select id,substring_index((substring(id,32)),'.',1) as tableID,mid(id ,56,8) as scrname,value as b from? fine_conf_entity? where id like '%DirectFieldConfStore.mapHolder%fieldId') as B
ON A.tableID=B.tableID? AND A.scrname=B.scrname
LEFT JOIN
(select id,substring_index((substring(id,32)),'.',1) as tableID,substring_index(id, '.', -1) as b,value as fieldnam from? fine_conf_entity? where id like
'DirectEntryConfStore.mapHolder.%.escapeMap.%') AS C
ON A.tableID=C.tableID and B.b=C.b
得到 BI 數(shù)據(jù)表字段信息如下圖所示:
5) 合并「BI數(shù)據(jù)原始信息」、「BI數(shù)據(jù)表顯示名」、「BI數(shù)據(jù)表業(yè)務(wù)包信息」、「數(shù)據(jù)表字段信息」為一個(gè)自助數(shù)據(jù)集。
實(shí)現(xiàn)步驟:
選擇「BI數(shù)據(jù)原始信息」下的所有字段,如下圖所示:
選擇「BI數(shù)據(jù)表顯示名」所有字段,點(diǎn)擊左合并,合并依賴為 tableId ,如下圖所示:
選擇「BI數(shù)據(jù)表業(yè)務(wù)包信息」內(nèi)的所有字段,點(diǎn)擊左合并,合并依賴為 tableId ,如下圖所示:
選擇「數(shù)據(jù)表字段信息」內(nèi)的所有字段,點(diǎn)擊左合并,合并依賴為 tableId ,如下圖所示:
創(chuàng)建新增列并命名為表顯示名,輸入公式IF(ISNULL(tableName),tableName,origName),如下圖所示:
創(chuàng)建新增列并命名為字段顯示名,輸入公式IF(ISNULL(fieldnam),filename,fieldnam),如下圖所示:
選擇 tableId、tableName、PackName、fieldnam、表顯示名、字段顯示名作為最終字段,并重命名為 表ID 、表名_原始、業(yè)務(wù)包名_原始、字段名_原始、表名_顯示名、字段名_顯示名。如下圖所示:
過(guò)濾掉表名_原始為空的數(shù)據(jù)(表名為空是 FineReport 模板),輸出最終字典自助數(shù)據(jù)集「BI數(shù)據(jù)表信息_處理」,如下圖所示:
6)將「BI數(shù)據(jù)表信息_處理」與數(shù)據(jù)庫(kù)中創(chuàng)建的「fine_data_dictionary」左合并,合并依據(jù)為表名、字段名、業(yè)務(wù)包名,合并為「BI數(shù)據(jù)字典」數(shù)據(jù)集,作為 FineReport 填報(bào)模板連接的 Spider 數(shù)據(jù)集,此后只需要使用模板填報(bào)以及自動(dòng)更新 BI 中的「數(shù)據(jù)字典」業(yè)務(wù)包即可。如下圖所示:
7)為數(shù)據(jù)字典整個(gè)業(yè)務(wù)包設(shè)置定時(shí)更新,以設(shè)置每小時(shí)更新一次為例,如下圖所示:
注:設(shè)置步驟詳情參見(jiàn):業(yè)務(wù)包更新 。若需要實(shí)時(shí)以及其他更新頻率可根據(jù)實(shí)際情況修改。
2.2 數(shù)據(jù)字典報(bào)表創(chuàng)建與維護(hù)
2.2.1 FineReport 遠(yuǎn)程連接 FineBI 獲取字典自助數(shù)據(jù)集
2.2.2 創(chuàng)建 Spider 數(shù)據(jù)集
1)創(chuàng)建 BI數(shù)據(jù)字典 Spider 數(shù)據(jù)集,如下圖所示:
2)創(chuàng)建表名過(guò)濾控件 Spider 數(shù)據(jù)集如下圖所示:
2.2.3 創(chuàng)建數(shù)據(jù)字典填報(bào)模板
1)將 BI 數(shù)據(jù)字典數(shù)據(jù)集下的所有字段按照順序拖入單元格并設(shè)置單元格顏色和單元格框,如下圖所示:
2)對(duì)數(shù)據(jù)示例、業(yè)務(wù)計(jì)算邏輯、應(yīng)用范圍單元格設(shè)置?填報(bào)控件 和?報(bào)表填報(bào)屬性 ,并給單元格設(shè)置編輯結(jié)束事件,如下圖所示:
3)在模板>報(bào)表填報(bào)屬性中添加內(nèi)置 SQL ,如下圖所示:
4)在插入>單元格元素>插入富文本下,添加富文本,如下圖所示:
5)在參數(shù)面板中設(shè)置標(biāo)簽控件、下拉復(fù)選框控件?以及查詢按鈕,如下圖所示:
2.3 數(shù)據(jù)字典模板使用與數(shù)據(jù)字典維護(hù)
1)登錄數(shù)據(jù)決策系統(tǒng),掛出該填報(bào)模板,如下圖所示:
詳情參見(jiàn):管理目錄 。
2)在目錄中查看該模板并填報(bào),如下圖所示:
3)若填報(bào)模板正常,則可以給不同用戶開(kāi)放權(quán)限,共同維護(hù)數(shù)據(jù)字典。詳情參見(jiàn):分級(jí)權(quán)限分配 。
總結(jié)
以上是生活随笔為你收集整理的以mysql为例的数据字典_建立数据字典的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 做有意义的事
- 下一篇: SI 9000 及阻抗匹配学习笔记(三)