以mysql为例的数据字典_建立数据字典
本例以 MySQL 數據庫為例。
2.1 連接 FineDB 數據庫
2.1.1 為 FineBI 設置外接數據庫
1)新建「finedb」數據庫,數據庫名必須為「finedb」,設置默認字符集排序規則為 utf_bin( mysql 數據庫需要設置排序規則為 utf8_bin),如下圖所示:
2) FineBI 連接外接數據庫,如下圖所示:
3)在 FineBI 中新建數據連接,連接到外接數據庫,測試連接成功,點擊保存,如下圖所示:
詳情參見:配置數據連接 。
4)在數據準備界面可查看數據庫以及數據庫表,如下圖所示:
5)在外接數據庫中新建「fine_data_dictionary」數據庫表,表字段、類型、注釋如下圖所示:
注:這張表是數據字典維護表, IT 和業務維護的數據字典會存入這張表中。其中業務包名、表名、字段名是必須的,其余字段可以修改,按實際使用增加,填報時拉入字段即可。
2.1.2 獲取相關數據
1)添加?SQL 數據集,獲取 BI 中所有表原始信息。
輸入 SQL 語句如下所示: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 #對應配置表名
className like 'com.finebi.common.internalimp.config%' #數據表過濾
)
) as A
left join
fine_conf_classname as B
on A.id = B.id
得到 BI 數據原始信息如下圖所示:
2)添加?SQL 數據集,獲取 BI 數據表顯示名。
SQL 語句如下所示:
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 數據顯示名如下圖所示:
3)添加?SQL 數據集,獲取 BI 所有業務包信息。
SQL 語句如下所示:
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 #對應配置表名
className like 'com.finebi.common.internalimp.config%' #數據表過濾
)
) 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 數據業務包信息如下圖所示:
4)添加?SQL 數據集,獲取 BI 數據表字段信息。
SQL 語句如下所示:
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 數據表字段信息如下圖所示:
5) 合并「BI數據原始信息」、「BI數據表顯示名」、「BI數據表業務包信息」、「數據表字段信息」為一個自助數據集。
實現步驟:
選擇「BI數據原始信息」下的所有字段,如下圖所示:
選擇「BI數據表顯示名」所有字段,點擊左合并,合并依賴為 tableId ,如下圖所示:
選擇「BI數據表業務包信息」內的所有字段,點擊左合并,合并依賴為 tableId ,如下圖所示:
選擇「數據表字段信息」內的所有字段,點擊左合并,合并依賴為 tableId ,如下圖所示:
創建新增列并命名為表顯示名,輸入公式IF(ISNULL(tableName),tableName,origName),如下圖所示:
創建新增列并命名為字段顯示名,輸入公式IF(ISNULL(fieldnam),filename,fieldnam),如下圖所示:
選擇 tableId、tableName、PackName、fieldnam、表顯示名、字段顯示名作為最終字段,并重命名為 表ID 、表名_原始、業務包名_原始、字段名_原始、表名_顯示名、字段名_顯示名。如下圖所示:
過濾掉表名_原始為空的數據(表名為空是 FineReport 模板),輸出最終字典自助數據集「BI數據表信息_處理」,如下圖所示:
6)將「BI數據表信息_處理」與數據庫中創建的「fine_data_dictionary」左合并,合并依據為表名、字段名、業務包名,合并為「BI數據字典」數據集,作為 FineReport 填報模板連接的 Spider 數據集,此后只需要使用模板填報以及自動更新 BI 中的「數據字典」業務包即可。如下圖所示:
7)為數據字典整個業務包設置定時更新,以設置每小時更新一次為例,如下圖所示:
注:設置步驟詳情參見:業務包更新 。若需要實時以及其他更新頻率可根據實際情況修改。
2.2 數據字典報表創建與維護
2.2.1 FineReport 遠程連接 FineBI 獲取字典自助數據集
2.2.2 創建 Spider 數據集
1)創建 BI數據字典 Spider 數據集,如下圖所示:
2)創建表名過濾控件 Spider 數據集如下圖所示:
2.2.3 創建數據字典填報模板
1)將 BI 數據字典數據集下的所有字段按照順序拖入單元格并設置單元格顏色和單元格框,如下圖所示:
2)對數據示例、業務計算邏輯、應用范圍單元格設置?填報控件 和?報表填報屬性 ,并給單元格設置編輯結束事件,如下圖所示:
3)在模板>報表填報屬性中添加內置 SQL ,如下圖所示:
4)在插入>單元格元素>插入富文本下,添加富文本,如下圖所示:
5)在參數面板中設置標簽控件、下拉復選框控件?以及查詢按鈕,如下圖所示:
2.3 數據字典模板使用與數據字典維護
1)登錄數據決策系統,掛出該填報模板,如下圖所示:
詳情參見:管理目錄 。
2)在目錄中查看該模板并填報,如下圖所示:
3)若填報模板正常,則可以給不同用戶開放權限,共同維護數據字典。詳情參見:分級權限分配 。
總結
以上是生活随笔為你收集整理的以mysql为例的数据字典_建立数据字典的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 做有意义的事
- 下一篇: 微软2008系列 (Orcas + Lo