全面理解xml文件

article/2025/10/12 1:36:27

XML

在这里插入图片描述

XML相关概念

概述:Extensible Markup Language 可扩展标记语言

  1. 功能
    • ​ 存储数据
      1. 配置文件
      2. 在网络中传输
  2. xmlhtml的区别
    1. XML标签都是自定义的,hmtl标签是预先定义的
    2. xml的语法严格,html语法松散
    3. XML是存储数据的,html是展示数据
  3. w3c万维网联盟

语法

基本语法
  1. xml文档的后缀名必须为.xml
  2. xml第一行必须定义为文档声明
  3. xml文档中有且仅有一要根标签【就是只能有一个根标签】
  4. 属性值必须使用双引号或单引号引起来
  5. 标签必须是有开始和有结束的
  6. xml是区分大小写的
快速入门
<?xml version="1.0" encoding="utf-8" ?><users><user id="1"><userName>海康</userName><age>20</age></user><user id="2"><userName>南宁</userName><age>21</age></user>
</users>
语法组成部分
  1. 文档声明

    1. 格式:<?xml 属性列表 ?>【注意第一个?号必须与xml紧张贴着,?< >不能有空格】

      1. 属性列表取值:
        • version:版本号,必须要写的属性
        • encodint:编码方式,告知解析引擎当前文档使用的字符集,默认是IS0-8859-1
        • standalone是否是独立的【了解】
          • 取值:yes是独立的【不依赖其他文件】,no是不独立的【依赖其他文件】
    2. 指令【了解】

      <?xml-stylesheet type="text/css" href="a.css" ?>

    3. 标签:标签名称自定义的

      1. 规则 :
        1. 名称可以包含字母,数字 ,以及其他的字符
        2. 名称不能以数字或者标点符号开始
        3. 名称不能以字母 xml(或者XML、Xml等等)开始
        4. 名称不能包含空格
    4. 属性:id属性值唯一

    5. 文本:使用CDATA区:在该区域数据会被原样展示

      格式: <![CDATA[ 数据 ]]>

xml语法中的约束

约束:规定xml文档的书写规则, 作为框架的使用者(程序员):
1. 能够在xml中引入约束文档
2. 能够简单的读懂约束文档

分类:

  • DTD约束:是一种简单的结束技术
  • Schema约束:一种复杂的约束技术
DTD约束

使用的步骤:

  1. 引入dtd文档到xml文档中【引入的方式有两种:内部和外部】
    • 内部dtd:将约束规则定义在xml文档中
    • 外部dtd:将约束规则定义在外部的dtd文件中【外部分为两种:本地和网络的】
      • 本地语法:本地:<!DOCTYPE 根标签名 SYSTEM "dtd文件的位置">
      • 网络语法:网络:<!DOCTYPE 根标签名 PUBLIC "dtd文件名字" "dtd文件的位置URL">【注意是:dtd文件名字任意的】
  2. 书写xml文件

dtd的缺点是:不能规定标签中的文本内容

案例:

第一步:书写dtd文档

<!ELEMENT students (student*) ><!--表示是根标签是students,子标签是student可以出现0到多次-->
<!ELEMENT student (name,age,sex)><!--student中的属性是name,age,sex,必须按照这个顺序书写-->
<!ELEMENT name (#PCDATA)><!--表示是字符串-->
<!ELEMENT age (#PCDATA)>
<!ELEMENT sex (#PCDATA)>
<!ATTLIST student number ID #REQUIRED><!--表示有ID且唯一-->

第二步:书写xml文档

<?xml version="1.0" encoding="UTF-8" ?>
<!--下面的语句表示引入dtd文档-->
<!DOCTYPE students SYSTEM "student.dtd"><students><student number="s_1"><name>海康</name><age>20</age><sex></sex></student>
</students>
Schema约束【文件的后缀是.xsd

使用的步骤:

  1. 编写xml文档的根元素

  2. 引入 xsi前缀

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"【是固定的】
    
  3. 引入 xsd文件命名空间

     xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsd">
    【注意是:表示一次性可以引入多个xsd约束】
    
  4. 为每一个xsd约束声明一个前缀,作为标识,方便区别使用的是那个约束

    xmlns="http://www.springframework.org/schema/beans"  表示这个是默认约束,不写前缀时,默认使用就是这个xmlns:context="http://www.springframework.org/schema/context" 表示前缀是 contextxmlns:mvc="http://www.springframework.org/schema/mvc"  表示前缀是 mvc
    

案例:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"  -- 表示这个beans是默认约束,不写前缀时,使用就它xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   --引入 `xsi`前缀xmlns:context="http://www.springframework.org/schema/context" --表示前缀是 contextxmlns:mvc="http://www.springframework.org/schema/mvc" --表示前缀是 mvcxsi:schemaLocation=" -- 引入多个不同约束http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsd"><context:annotation-config /> --表示使用context约束<mvc:resources mapping="/resources/**" location="/resources/" /> --表示使用mvc约束<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="suffix" value=".jsp" /></bean> --不写前缀表示使用的是默认约束</beans>

解析

解析:操作xml文档,将文档中的数据读取到内存中
操作xml文档

 		1. 解析(读取):将文档中的数据读取到内存中2. 写入:将内存中的数据保存到`xml`文档中。持久化的存储
解析xml的方式:
1. DOM:将标记语言文档一次性加载进内存,在内存中形成一颗dom树优点:操作方便,可以对文档进行CRUD的所有操作缺点:占内存
2. SAX:逐行读取,基于事件驱动的。优点:不占内存。缺点:只能读取,不能增删改
解析工具

xml常见的解析器:

 		1. `JAXP`:`sun`公司提供的解析器,支持`dom`和`sax`两种思想2. ` DOM4J`:一款非常优秀的解析器3. `Jsoup`:`jsoup` 是一款J`ava `的`HTML`解析器,可直接解析某个`URL`地址、`HTML`文本内容。它提供了一套非常省力的`API`,可通过`DOM,CSS`以及类似于`jQuery`的操作方法来取出和操作数据。【同时也可以解析`xml`】4. `PULL`:`Android`操作系统内置的解析器,`sax`方式的。

jsoup解析工具

jsoup的快速入门步骤:
  1. 导入相关jar
  2. 获取Document对象【使用的是JSoup静态方法parse
  3. 根据Document对象获取元素集合【使用的是getElementsByTag方法】
  4. 根据元素集合获取指定元素//根据ArrayList集合方法
  5. 获取指定元素中的文本【使用的是test方法】
package jsoup;/*** @author: 海康* @version: 1.0*/import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;/*** JSoup的快速入门*/
public class JSoupDome1 {public static void main(String[] args) throws IOException {//使用的步骤// 1.导入相关jar包// 2获取Document对象// 2.1相加相关xml文件String path = JSoupDome1.class.getClassLoader().getResource("introduction.xml").getPath();// 2.2使用Jsoup中静态方法parse获取一个Document对象Document parse = Jsoup.parse(new File(path), "utf-8");//3.根据Document对象获取元素集合//public class Elements extends ArrayList<Element>继承ArrayList集合说明可以当作ArrayList使用Elements userName = parse.getElementsByTag("userName");//4.根据元素集合获取指定元素//根据ArrayList集合方法Element element = userName.get(0);//5.获取元素中内容String text = element.text();//对象获取的内容进行打印System.out.println(text);}
}
JSoup工具类中对象

1.Jsoup:工具类,可以解析htmlxml文档,返回Document

常用方法parse并提供了重载方法

static Documentparse(File in, String charsetName)Parse the contents of a file as HTML.【常用】
static Documentparse(String html)Parse HTML into a Document.【了解】
static Documentparse(URL url, int timeoutMillis)Fetch a URL, and parse it as HTML.【通过网络中的url获取Document对象】

案例:

@Testpublic void method() throws IOException {/*** 对象parse方法【有三个常用的重载方法】常用方法进行说明*/// 方法一:【掌握】String path = JSoupDome1.class.getClassLoader().getResource("introduction.xml").getPath();// 2.2使用Jsoup中静态方法parse获取一个Document对象Document parse = Jsoup.parse(new File(path), "utf-8");System.out.println(parse);//方法二:【了解】Document document = Jsoup.parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +"<users>\n" +"    <user id=\"1\">\n" +"        <userName>海康</userName>\n" +"        <age>20</age>\n" +"    </user>\n" +"</users>");System.out.println(document);// 方法三:使用URL获取网上的html或xml文件【掌握】URL url = new URL("https://www.csdn.net/");Document parse1 = Jsoup.parse(url, 20000);//第二参数是设定超时的毫秒值System.out.println(parse1);}

2.Document对象:文档对象。代表内存中的dom树

获取ElementElements对象

常用方法:

ElementgetElementById(String id)Find an element by ID, including or under this element.【根据id获取一个Element对象】
ElementsgetElementsByAttribute(String key)Find elements that have a named attribute set.【根据键【属性名称】获取一个Elements对象】
ElementsgetElementsByAttributeValue(String key, String value)Find elements that have an attribute with the specific value【根据属性的键和值获取一个Elements对象】
ElementsgetElementsByTag(String tagName)Finds elements, including and recursively under this element, with the specified tag name.【根据名称获取一个Elements对象】

案例:

@Testpublic void testElement() throws IOException {// 根据id获取一个Element对象【注意是属性名一定是id,否则报错】//加载xml文件String path = JSoupDome1.class.getClassLoader().getResource("introduction.xml").getPath();Document parse = Jsoup.parse(new File(path), "utf-8");// 根据id获取一个Element对象【注意是属性名一定是id,否则获取是一个null值】Element eeje = parse.getElementById("eeje");System.out.println(eeje);System.out.println("============================");// 根据名称获取一个Element对象对象Elements users = parse.getElementsByTag("users");System.out.println(users);System.out.println("============================");// 根据一个键【就是标签中属性名】Elements对象Elements id = parse.getElementsByAttribute("id");System.out.println(id);System.out.println("============================");// 根据键值对象获取一个Elements对象Elements elements = parse.getElementsByAttributeValue("id", "eeje");System.out.println(elements);}<?xml version="1.0" encoding="utf-8" ?>
<users><user id="1"><userName>海康</userName><age>20</age></user><user id="2"><userName id="eeje">南宁</userName><age>21</age></user>
</users>

3.Elements:元素Element对象的集合。可以当做 ArrayList<Element>来使用

​ 使用Document返回一个Elements对象

4.Element:元素对象

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-c5Fr5vPK-1649680663780)(E:\Typora笔记\javaweb\IMG\image-20220411162830683.png)]

由于Document类继承于Element类在上述中的方法是来至Document类的

获取子元素对象方法:

ElementgetElementById(String id)Find an element by ID, including or under this element.【根据id获取一个Element对象】
ElementsgetElementsByAttribute(String key)Find elements that have a named attribute set.【根据键【属性名称】获取一个Elements对象】
ElementsgetElementsByAttributeValue(String key, String value)Find elements that have an attribute with the specific value【根据属性的键和值获取一个Elements对象】
ElementsgetElementsByTag(String tagName)Finds elements, including and recursively under this element, with the specified tag name.【根据名称获取一个Elements对象】

获取属性值:

tringattr(String attributeKey)Get an attribute’s value by its key.【根据属性名获取属性值value

获取文本内容:

Stringtext()Gets the combined text of this element and all its children【获取标签中的文本内容】
Stringhtml()Retrieves the element’s inner HTML.【与text方法的区别是:html是获取所有的标签加标签中的文本内容,而test只获取标签中的内容】

案例:

 @Testpublic void elementMethod() throws IOException {// 根据id获取一个Element对象【注意是属性名一定是id,否则报错】//加载xml文件String path = JSoupDome1.class.getClassLoader().getResource("introduction.xml").getPath();Document parse = Jsoup.parse(new File(path), "utf-8");//获取Elements对象Elements user = parse.getElementsByTag("user");System.out.println(user.size());System.out.println("==================");//获取Element对象【就是获取一个子标签】Elements elementsByTag = parse.getElementsByTag("user");Element element = elementsByTag.get(0);//获取一个Element对象//属性值:根据属性名称获取属性值String id = element.attr("id");//根据标签中的属性名获取标签中属性的值System.out.println(id);//id="1_1"// 文本内容String text = element.text();String html = element.html();System.out.println(text);//返回:海康 20System.out.println(html);/*** 返回* <username>*  海康* </username>* <age>*  20* </age>*/}<?xml version="1.0" encoding="utf-8" ?>
<users><user id="1_1"><userName >海康</userName><age>20</age></user><user id="2"><userName id="eeje">南宁</userName><age>21</age></user>
</users>

node:节点对象

DocumentElement的父类

快捷查询方式

有两种查询方式:

  1. selector:选择器
  2. XPahtXPath即为XML路径语言,它是一种用来确定xml(标准通用标记语言的子集)文档中某个部分位置的语言
selector选择器方式

使用的方法是:

Elementsselect(String cssQuery)Find elements that match the Selector CSS query, with this element as the starting context.【根据文本标签获取】

语法需要参考Selector类中定义的方法

Selector选择器概述

  • tagname: 通过标签查找元素,比如:a
  • ns|tag: 通过标签在命名空间查找元素,比如:可以用 fb|name 语法来查找 <fb:name> 元素
  • #id: 通过ID查找元素,比如:#logo
  • .class: 通过class名称查找元素,比如:.masthead
  • [attribute]: 利用属性查找元素,比如:[href]
  • [^attr]: 利用属性名前缀来查找元素,比如:可以用[^data-] 来查找带有HTML5 Dataset属性的元素
  • [attr=value]: 利用属性值来查找元素,比如:[width=500]
  • [attr^=value], [attr$=value], [attr*=value]: 利用匹配属性值开头、结尾或包含属性值来查找元素,比如:[href*=/path/]
  • [attr~=regex]: 利用属性值匹配正则表达式来查找元素,比如: img[src~=(?i)\.(png|jpe?g)]
  • *: 这个符号将匹配所有元素

Selector选择器组合使用

  • el#id: 元素+ID,比如: div#logo
  • el.class: 元素+class,比如: div.masthead
  • el[attr]: 元素+class,比如: a[href]
  • 任意组合,比如:a[href].highlight
  • ancestor child: 查找某个元素下子元素,比如:可以用.body p 查找在"body"元素下的所有 p元素
  • parent > child: 查找某个父元素下的直接子元素,比如:可以用div.content > p 查找 p 元素,也可以用body > * 查找body标签下所有直接子元素
  • siblingA + siblingB: 查找在A元素之前第一个同级元素B,比如:div.head + div
  • siblingA ~ siblingX: 查找A元素之前的同级X元素,比如:h1 ~ p
  • el, el, el:多个选择器组合,查找匹配任一选择器的唯一元素,例如:div.masthead, div.logo

案例:

public static void main(String[] args) throws IOException {URL resource = JsoupSelector.class.getClassLoader().getResource("introduction.xml");String path = resource.getPath();Document parse = Jsoup.parse(new File(path), "utf-8");// 注意是:一般都是使用Document对象,因为继承了Element功能更强大//查询标签名为userNameElements userName = parse.select("userName");System.out.println(userName);System.out.println("======================");//查询id值为1_1的元素Elements id = parse.select("#1_1");System.out.println(id);System.out.println("========================");// 查询user标签并且id属性值为1_1的age子标签// 步骤1:获取user标签并且id属性值为1_1Elements select = parse.select("user[id='1_1']");System.out.println(select);System.out.println("===============");// 步骤2:获取user标签中的子标签ageElements age = parse.select("user[id='1_1'] > age");System.out.println(age);}
XPath查询方式

XPath查询:XPath即为XML路径语言,它是一种用来确定XML(标准通用标记语言的子集)文档中某部分位置的语言

XPath使用步骤:

  1. 导入使用JSoupXPath需要额外的jar
  2. 由于Document对象,不支持XPath语法,所以需要创建一个JXDocument对象,并将Doc树传入JXDocument对象本质是JXDocument操作是DOC树】
  3. 获取一个标签对象,进行相关的操作

案例:

/*** @author: 海康* @version: 1.0*/
public class XPath {public static void main(String[] args) throws IOException, XpathSyntaxErrorException {//加载 introduction.xml 文件String path = XPath.class.getClassLoader().getResource("introduction.xml").getPath();Document parse = Jsoup.parse(new File(path), "utf-8");//获取一个DOM树// 由于Document不支持 XPath语法,需要JXDocument对象,将DOM树传入JXDocument jxDocument = new JXDocument(parse);// 获取所有user标签List<JXNode> user = jxDocument.selN("//user");// 遍历所有user标签for (JXNode jxNode:user) {System.out.println(jxNode);}System.out.println("====================");// 查询所有user标签下userName标签List<JXNode> userName = jxDocument.selN("//user/userName");// 遍历所有userName标签for (JXNode jxNode:userName) {System.out.println(jxNode);}//查询user标签下userName标签有id的标签List<JXNode> jxNodes = jxDocument.selN("//user/userName[@id]");System.out.println(jxNodes);// 查询user标签下userName标签有id的标签并且id值为eejeJXNode jxNode = jxDocument.selNOne("//user/userName[@id='eeje']");System.out.println(jxNode);}
}

http://chatgpt.dhexx.cn/article/uOrKPXCC.shtml

相关文章

Java数组和方法

一、数组 1.定义&#xff1a;数组(array)是一种用于存储多个相同类型数据的存储模型。 格式1&#xff1a;数据类型[] 变量名 &#xff08;推荐使用&#xff09; 例子&#xff1a; int[ ] arr 定义了一个int类型数组&#xff0c;数组名是arr 格式2&#xff1a;数据类型 变量…

总结JS中常用的数组的方法大全

总结JS中常用的数组方法 JS中常用的数组方法总结 数组(Array)是一种复杂的数据类型&#xff0c;它属于Object(对象)类型&#xff0c;用来将一组数组合在一起&#xff0c;通过一个变量就可以访问一组数据。在使用数组时&#xff0c;经常会搭配循环语句使用&#xff0c;从而很方便…

17种数组常用方法

数组的常用方法&#xff08;内置方法&#xff1a;直接使用&#xff0c;只需按要求传递对应的参数&#xff09; 标红的为重点 一维数组&#xff1a;数组元素只有一个下标&#xff08;通过一个下标就可以定位数组中的元素&#xff09; 1.join(连接字符)&#xff1a;作用是将数…

Array数组的方法

1.Array.from() 将类数组结构转化为数组实例&#xff0c; 一参数是类数组对象即任何可迭代的结构&#xff0c;或者有一个length属性和可索引元素的结构 二参数是映射函数参数&#xff08;可选&#xff09;此函数可增强新函数的值&#xff0c; 三参数是指定映射函数中的this…

常用处理数组的方法

常用处理数组的方法 一、Es5 1.Arr.map() 数组中的每个元素会执行一次回调函数&#xff0c;结果作为一个新的数组返回&#xff0c;不改变原数组let arr [1, 2, 3, 4, 5] let newArr arr.map(x > {return x*2 // 将数组的每一项乘以2 }) console.log(newArr) // [2, 4, …

JS数组常用方法整理(14种常用方法)

目录 1.增 1.1 push(): 1.2 unshift(): 2.删 2.1 pop(): 2.2 shift() 3.改&#xff08;增、删&#xff09;&#xff1a; 3.1 splice() 4.查 4.1 slice() 5.将数组转换为字符串&#xff1a; 5.1 toString() 5.2 join() 6.数组拼接 6.1concat() 7.检测数组中是否包…

总结: 数组常用的方法

在实际开发当中, 数组和对象使用到最多的; 数组和对象有很多的方法, 这里主要探讨一下: 数组的增删改查数组的排序方式数组转换成其他数据类型的方式ES6数组新增常用的迭代方式 为什么需要数组? 数组可以存入不限数的数据, 并且可以使用下标值进行访问; 数据在数组的内部是有…

hive 宽表变竖表 长表变宽表

1.这是源数据以及需要转化的目标表. 我们的方法是 , 用 GROUP BY按照year分组 , 并且依次提取1月,2月,3月,4月的 num,具体实现 1 2 3 4 5 6 select year, max(case when month1 then money else 0 end) as M1, max(case when month2 then money else 0 end) as M2, max(case w…

【pandas】变形(长宽表变换)

变形 长宽表的变形 长表变宽表就是一个分类变量的多个值展开成多个变量&#xff0c;和哑变量变换有点相似&#xff0c;但不是0-1编码而是其他变量的值。 宽表变长表类似&#xff0c;多个类别可以化在一个分类变量下。 pivot pivot是一种典型的长表变宽表的函数&#xff0c;…

数据库设计--大宽表

宽表的概念 基本概念 宽表从字面意义上讲就是字段比较多的数据库表。通常是指业务主题相关的指标、维度、属性关联在一起的一张数据库表。 由于把不同的内容都放在同一张表存储&#xff0c;宽表已经不符合三范式的模型设计规范&#xff0c;随之带来的主要坏处就是数据的大量冗…

Flink cdc+ doris 大宽表实践~

还没整理好&#xff0c;别慌。 一&#xff0c;业务问题&#xff1a; 多个表关联join&#xff08;涉及时间维度跨度很长&#xff09;&#xff0c;几乎等同于全量关联&#xff0c;这个时候flink sql join没法做&#xff0c;因为state会无线增大&#xff0c;然后OOM。 二&#xf…

实现MySQL同步数据到ES构建宽表

作者介绍 Ceven&#xff0c;德勤乐融(北京)科技有限公司 邮箱&#xff1a;likailindeqinyuerong.com 前言 CloudCanal 近期提供了自定义代码构建宽表能力&#xff0c;我们第一时间参与了该特性内测&#xff0c;效果不错。开发流程详见官方文档 《CloudCanal自定义代码实时加…

宽表:数据仓库 - “宽表”之争?

昨天在技术交流群里一个问题引发了激烈的讨论&#xff0c;我决定把它记录下来。 问题如下&#xff1a;DWD 中有宽表么&#xff1f; 作为扫盲文章&#xff0c;基础知识我们再普及一下&#xff0c;先介绍下基础相关概念。 数仓分层&#xff08;来自&#xff1a;个人理解&#xff…

Elasticseach:从微服务架构演变到大宽表思维的架构转变

序言 图示&#xff1a;Elasticsearch 在DB-Engine综合排名第8 Elasticsearch 简称"ES”, 在DB-Engine 综合排名第8&#xff0c;已经持续了相当长的时间&#xff0c;按照当下热度应该会继续保持或者上升一个名次&#xff1b;ES在多数工程师印象中最深刻可能是ELK三件套或者…

9.Flink实时项目之订单宽表

1.需求分析 订单是统计分析的重要的对象&#xff0c;围绕订单有很多的维度统计需求&#xff0c;比如用户、地区、商品、品类、品牌等等。为了之后统计计算更加方便&#xff0c;减少大表之间的关联&#xff0c;所以在实时计算过程中将围绕订单的相关数据整合成为一张订单的宽表…

数仓建模—宽表的设计

宽表的设计 高内聚低耦合 宽表是数仓里面非常重要的一块&#xff0c;数仓是分层的&#xff0c;这是技术进步和时代变化相结合的产物&#xff0c;数仓的分层式为了更好地管理数仓以及更加高效地进行数据开发。 宽表主要出现在dwd 层和报表层&#xff0c;当然有的人说dws 层也有…

基于宽表的数据建模应用

一、业务背景 1.1 数据建模现状 互联网企业往往存在多个产品线&#xff0c;每天源源不断产出大量数据&#xff0c;这些数据服务于数据分析师、业务上的产品经理、运营、数据开发人员等各角色。为了满足这些角色的各种需求&#xff0c;业界传统数仓常采用的是经典分层模型的数…

数据仓库宽表

1. 构建宽表的目的 讲宽表我想从为什么需要宽表入手&#xff0c;而不是一上来就抠概念。因为我觉得一门知识叫什么名字并不是最核心的&#xff0c;关键是搞清楚它的诞生背景以及如何在特定场景用好它。 构建宽表的目的很简单,就是为了"一站式"尽可能多的展示我们需要…

宽表, 窄表, 维度表, 事实表的区别

在数据开发里, 会涉及到一些概念: 宽表, 窄表, 维度表, 事实表 宽表: 把多个维度的字段都放在一张表存储, 增加数据冗余是为了减少关联, 便于查询. 查询一张表就可以查出不同维度的多个字段窄表: 和我们 mysql 普通表三范式相同, 把相同维度的字段组成一张表, 表和表之间关联查…

[转]科普 | 什么是宽表?

科普 | 什么是宽表&#xff1f;一文带你了解 数据仓库宽表_数据宽表_吕归尘0的博客-CSDN博客 一、什么是“宽表”&#xff1f; “宽表”从字面上的意思就是字段&#xff08;列&#xff09;比较多的数据库表&#xff0c;是通过关联字段将多个业务主题相关的数据表进行挂接组装…