113
CC3201-1 BASES DE D ATOS PRIMAVERA 2016 Clase 14: Datos Semiestructurados: Grafos Aidan Hogan [email protected]

CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

CC3201-1BASES DE DATOS

PRIMAVERA 2016

Clase 14: Datos Semiestructurados: Grafos

Aidan Hogan

[email protected]

Page 2: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

MODELOS DE DATOS

Page 3: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Modelo de datos (tabla)

Page 4: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Modelo de datos (árbol/jerarquía)

¿Es un “verdadero” árbol?

Umm … sí y no.

Es feo tener tres nodos para Ale (y es más difícil consultar)

Page 5: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Modelo de datos (árbol/jerarquía)

¿Es un árbol ahora?

Hay ciclos, entonces ¡no!

¿Aparte de eso, H.A.P.A.?

¿De dónde es Kross 5?

Page 6: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Modelo de datos (árbol/jerarquía)

Page 7: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Modelo de datos (árbol/jerarquía)

Page 8: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Modelo de datos (grafo)

Un grafo dirigido con arcos etiquetados

Page 9: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Grafo dirigido …

¿El problema sin dirección?

¿Curacaví es el origen de Kross 5 o Kross 5 es el origen de Curacavía?

Page 10: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Grafo con arcos etiquetados

¿El problema sin etiquetas sobre los arcos?

No sabemos la relación entre Ale y Kross Golden, por ejemplo.

Page 11: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Un grafo dirigido con arcos etiquetados

Page 12: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Un grafo dirigido con arcos etiquetados

Page 13: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

El espectro de la estructura de datos

Relacional(SQL, CSV, …)

Grafos(RDF, Prop. Gs, …)

Arboles(XML, JSON, …)

Texto Enriquecido(HTML, Word, …)

Texto PlanoNo estructurados

Estructurados

Semiestructurados

D

A

T

O

S

Page 14: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Para arboles, tenemos formatos como XML

¿Hay un formato para grafos?

¿Cómo podríamos definir una sintaxis para grafos?

Page 15: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Para grafos, podemos usar triples

No hay orden.

Page 16: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

DATOS SEMIESTRUCTURADOS:GRAFOS (TRIPLES)

Page 17: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Relacional(SQL, CSV, …)

Grafos(RDF, Prop. Gs, …)

Arboles(XML, JSON, …)

Texto Enriquecido(HTML, Word, …)

Texto PlanoNo estructurados

Estructurados

Semiestructurados

D

A

T

O

S

Page 18: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Datos semiestructurados …

Los usuarios pueden agregar más atributos.

Muchos atributos pueden tener cero o más valores.

Datos son incompletos.

Page 19: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: XML (Arbol)

Page 20: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

Page 21: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

Page 22: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

Si no hay un valor, simplemente se puede omitir el valor

¿H.A.P.A.? Usamos los nodos Bronn y Drogo como nombre y personaje

Page 23: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

Podemos considerar varios tipos de nodos (“string”, nodo complejo)

Page 24: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

Podemos considerar varios tipos de nodos (string, int, boolean, etc.)

Page 25: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

Page 26: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

Un nodo puede enlazar a varios nodos con el mismo etiqueta de arco

Page 27: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

Page 28: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

Page 29: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

Page 30: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

¿Cómo podemos decir que Callum Warryfue el primer actor de Tommen y Dean C.

Chapman el segundo?

Page 31: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

Hay que representar orden “por mano”.

¿Cómo podemos decir que Callum Warryfue el primer actor de Tommen y Dean C.

Chapman el segundo?

Page 32: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

¿Cómo podemos decir que Callum Warryfue el actor de Tommen desde el

episodio 1 y Dean C. Chapman fue desde el episodio 31?

Page 33: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Juego de Datos: Grafos

¿Cómo podemos decir que Callum Warryfue el actor de Tommen desde el

episodio 1 y Dean C. Chapman fue desde el episodio 31?

Si una relación no es binaria, se puede usar un nodo para representar la

relación.

(Se puede representar orden de esta manera también.)

Page 34: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Dean-Charles Chapman

Page 35: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

… grafos son más flexible que datos relacionales (y arboles) también.

La conclusión de esta parte …

Page 36: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

¿PERO DÓNDE SE USAN GRAFOS?

Page 37: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

La Web de Datos / La Web Semantica

Page 38: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

¡La Web es magnífica!

¿Pero puede ser mejor? … a veces es difícil encontrar información relevante.

Page 39: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

¡Pero Google es magnífico!

Page 40: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Se pueden encontrar respuestas directas

Page 41: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Haciendo un informe para su clase …

Quiere encontrar cada:

– Ganadores del Premio Nobel en Literatura

– Que han luchado en una guerra

– El año que ganaron el premio

– Y el año que comenzó la guerra

¿Cómo se puede encontrar esta información con la Web actual?

Page 42: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Muchas pestañas de Wikipedia …

Page 43: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

La Web en el espectro de datos

Relacional(SQL, CSV, …)

Grafos(RDF, Prop. Gs, …)

Arboles(XML, JSON, …)

Texto Enriquecido(HTML, Word, …)

Texto PlanoNo estructurados

Estructurados

Semiestructurados

D

A

T

O

S

Page 44: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

La Web Semántica …

… una base de datos global usando la Web

Page 45: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

La Web de Datos en el espectro de datos

No estructurados

Estructurados

Semiestructurados

D

A

T

O

S

¿Y si quisiéramos estructurar los datos de la Web y crear

una Web de Datos, donde la pondríamos en el espectro?

Relacional(SQL, CSV, …)

Grafos(RDF, Prop. Gs, …)

Arboles(XML, JSON, …)

Texto Enriquecido(HTML, Word, …)

Texto Plano

Imaginemos el esquema relacional. :/

Page 46: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

La Web de Datos en el espectro de datos

No estructurados

Estructurados

Semiestructurados

D

A

T

O

S

¿Y si quisiéramos estructurar los datos de la Web y crear

una Web de Datos, donde la pondríamos en el espectro?

Relacional(SQL, CSV, …)

Grafos(RDF, Prop. Gs, …)

Arboles(XML, JSON, …)

Texto Enriquecido(HTML, Word, …)

Texto Plano

Parece más razonable usar grafos dado su flexibilidad

¿Pero qué formato de datos podemos ocupar entonces?

Page 47: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

RESOURCE DESCRIPTION FORMAT(RDF)

Formato de Descripción de Recursos

Page 48: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Modelando el mundo con triples

Page 49: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

¿Agregar información? Concatenar triples.

Page 50: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Los triples representan un grafo

Page 51: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Los triples representan un grafo

Page 52: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Idea: Usar los identificadores de la Web

• URL: Uniform Resource Location– La ubicación de un recurso de la Web – (e.g., una pagina Web)– http://ex.org/Dubl%C3%ADn.html

• URI: Uniform Resource Identifier (RDF 1.0)– Un identificador de un recurso general– (e.g., una ciudad)– http://ex.org/Dubl%C3%ADn

• IRI: Internationalised Resource Identifier (RDF 1.1)– Una URI que permite caracteres en Unicode– http://ex.org/Dublín

Page 53: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Usaremos IRIs con prefijos

http://ex.org/Dublín ↔ ex:Dublín

• “ex:” denota un prefijo para http://ex.org/

• “Dublín” en un nombre local

Prefijos comunes:

Page 54: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Desde strings …

Page 55: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

… hasta identificadores de la Web …

Page 56: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

… ¿y qué pasa con números, etc.? …

¿Deberíamos asignar IRIs a números, booleanos, etc.?

Page 57: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Literals representan “valores” …

… como strings, numeros, booleanos, fechas …

• Pero solo se permiten como objeto

Page 58: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Se usan los tipos de XML Schema

Page 59: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Se usan los tipos de XML Schema

Por defecto un string

Page 60: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Se pueden usar etiquetas de idiomas

Etiquetas de idoma

Page 61: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: SPARQL PROTOCOL AND RDF QUERY LANGAUGE

Protocolo y Lenguaje de Consulta de RDF:

Page 62: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase
Page 63: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: Consultar Grafos en RDF

Consulta: “Quién protagoniza en la película ‘Sharknado’?”

Page 64: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: Consultar Grafos en RDF

Consulta: Soluciones:

Page 65: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL Prefijos: Abreviaturas de IRIs

Page 66: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: clausula de WHERE

• Donde se produce la magia

• Especifica un grafo de consulta

“Patrón triple”

(un triple con variables)

Page 67: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: clausula de WHERE

Page 68: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: clausula de WHERE

Consulta: “¿En cuales (otras) películas los actores de Sharknado han actuado?”

Page 69: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: clausula de WHERE

Page 70: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: clausula de WHERE

“Basic Graph Pattern”

(un conjunto de pátrones triples)

Page 71: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: Joins

“Variable de Join”

(una variable en múltiples lugares)

Page 72: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: Unión

Consulta: “¿Qué son los títulos del las dos primeras películas en la serie Sharkando?”

Page 73: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: Unión

Page 74: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: Left-join (OPTIONAL)

Consulta: “¿Los títulos de películas y (cuando sea disponible) sus fechas de estreno?”

Page 75: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: Left-join (OPTIONAL)

“Variable UNBOUND”

(una variable sin una solución)

Page 76: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: Filtros

Consulta: “Cuales películas estrenaron en 2014?”

Page 77: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: Filtros

Resultados vacíos

Page 78: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: Filtros

Una abreviatura

Page 79: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: clausula de WHERE (otro ejemplo)

Page 80: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: clausula de WHERE (otro ejemplo)

Como NOT EXISTS/EXCEPT!

Page 81: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: SELECT con *

Page 82: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: SELECT con proyección

Devuelveduplicados

Page 83: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: SELECT con DISTINCT

(no hay duplicados)

Page 84: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: ASK

true si hay al menos un resultado,

false si no.

Page 85: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

SPARQL: CONSTRUCT

Devuelve un grafo de RDF

Page 86: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Modificadores: ORDER BY, LIMIT, OFFSET

Consulta: “La segunda película y la tercera película más recientes”

Page 87: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Expresiones de Caminos: “Property paths”

Consulta: “Los actores con un ‘Número de Bacon’ finito”

Page 88: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

LA WEB DE DATOS … HOY EN DÍA

Page 89: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

GOOGLE’S “RICH SNIPPETS”

Page 90: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Resultados lujosos …

¿Pero cómo sabe Google del rating, calorías, duración, etc.?

Page 91: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Datos anidados en los documentos

La pública recibe más clics

Google puede crear resultados lujosos

Page 92: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

schema.org (Bing, Google, Yahoo!, Yandex)

92

Page 93: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

GOOGLE’S KNOWLEDGE GRAPH

Page 94: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Google: “Info-box”

Page 95: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Google: Búsqueda Semántica

Page 96: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Datos estructurados como grafos …

Page 97: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

FACEBOOK OPEN GRAPH PROTOCOL

Page 98: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Mientras tanto en Facebook …

Facebook quiere saber alguna información de los

documentos con enlaces en los comentarios

Page 99: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Mientras tanto en la Web …

Facebook quiere saber alguna información sobre las cosas que uno puede “Like” en la Web externa

Page 100: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Facebook Open Graph Protocol

Page 101: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

DATA-FYING WIKIPEDIA:WIKIDATA

Page 102: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

¿Qué es Wikidata?

Page 103: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Wikipedia: Varios Idiomas

Page 104: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Wikipedia: Listas, etc.

Page 105: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Alexis marca un gól …

Ahora un ejército de personas tienen que actualizar Wikipedia

(texto, listas, idiomas, etc.)

Page 106: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Una solución: Wikidata

Page 107: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Wikidata: datos estructurados

Page 108: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Servicio de consulta (SPARQL):

Page 109: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Servicio de consulta (SPARQL):

Page 110: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

EN CONCLUSIÓN

Page 111: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Una área de investigación aquí …

Page 112: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Datos ≠ Datos Relacionales

Page 113: CC3201-1 B DATOS P 2016 Clase 14: Datos Semiestructurados: …aidanhogan.com/teaching/cc3201-1-2016/lectures/BdD2016... · 2016-12-07 · CC3201-1 BASES DE DATOS PRIMAVERA 2016 Clase

Preguntas?