Question

In: Computer Science

List the primary additional datatypes used in a spatial database and provide two example queries that...

List the primary additional datatypes used in a spatial database and provide two example queries that can be run against these datatypes.

Explain the differences in data representation between key:value and document databases. In your answer describe the format of a JSON document, and give an example of a query in a document database

Solutions

Expert Solution

Some of the primary additional datatypes using spatial database are as follows:

  • Geometry spatial data type
  • geography spatial data type

Example of Geometry spatial data type:

CREATE TABLE SpatialTable   
    ( id int IDENTITY (1,1),  
    GeomCol1 geometry,   
    GeomCol2 AS GeomCol1.STAsText() );  
GO  
  
INSERT INTO SpatialTable (GeomCol1)  
VALUES (geometry::STGeomFromText('LINESTRING (100 100, 20 180, 180 180)', 0));  
  
INSERT INTO SpatialTable (GeomCol1)  
VALUES (geometry::STGeomFromText('POLYGON ((0 0, 150 0, 150 150, 0 150, 0 0))', 0));  
GO 

Example of Geography spatial data type:

CREATE TABLE SpatialTable   
    ( id int IDENTITY (1,1),  
    GeogCol1 geography,   
    GeogCol2 AS GeogCol1.STAsText() );  
GO  
  
INSERT INTO SpatialTable (GeogCol1)  
VALUES (geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656 )', 4326));  
  
INSERT INTO SpatialTable (GeogCol1)  
VALUES (geography::STGeomFromText('POLYGON((-122.358 47.653 , -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326));  
GO  

differences in data representation between key:value and document databases:

Ans:  

A document database is, at its core, a key/value store with one major exception. Instead of just storing any blob in it, a document db requires that the data will be store in a format that the database can understand (i.e. JSON, XML etc). In most doc dbs, that means that we can now allow queries on the document data.

Format of JSON document:

JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. Squarespace uses JSON to store and organize site content created with the CMS.

Example query for JSON document:

DECLARE @json NVARCHAR(MAX);
SET @json = N'[
  {"id": 2, "info": {"name": "John", "surname": "Smith"}, "age": 25},
  {"id": 5, "info": {"name": "Jane", "surname": "Smith"}, "dob": "2005-11-04T12:00:00"}
]';

SELECT *
FROM OPENJSON(@json)
  WITH (
    id INT 'strict $.id',
    firstName NVARCHAR(50) '$.info.name',
    lastName NVARCHAR(50) '$.info.surname',
    age INT,
    dateOfBirth DATETIME2 '$.dob'
  );
Let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

Related Solutions

Demonstrate how a temporal database is used in business Explain how spatial databases are used in...
Demonstrate how a temporal database is used in business Explain how spatial databases are used in business Explain how SQL is used with spatial databases Explain how NoSQL databases are being used to store unstructured business data
Discuss the mechanism of primary active transport and provide an example of how it is used...
Discuss the mechanism of primary active transport and provide an example of how it is used in the kidney.
Create the following SQL queries using the lyrics database below 1. List the first name, last...
Create the following SQL queries using the lyrics database below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in seconds 4....
Identify two types of statistical analyses used in research and provide an example.
Identify two types of statistical analyses used in research and provide an example.
Provide an example of a company that is debt adverse, but could drive additional earnings by...
Provide an example of a company that is debt adverse, but could drive additional earnings by increasing their debt load.
Provide an example of a company that is debt adverse, but could drive additional earnings by...
Provide an example of a company that is debt adverse, but could drive additional earnings by increasing their debt load.
Question 2. The following tables provide some example data that will be kept in the database....
Question 2. The following tables provide some example data that will be kept in the database. Write the INSERT commands necessary to place the following data in the tables that were created in Question 1. Alternatively provide the text files (copy and pasted into your final report) and the open/insert from file commands.. Table: actor act_id | act_fname | act_lname | act_gender 101 | James | Stewart | M 102 | Deborah | Kerr | F 103 | Peter |...
Using the below two SQL queries and comments below, provide explanation on why the output count...
Using the below two SQL queries and comments below, provide explanation on why the output count varies and which SQL yield correct result. (20 points) Both SQLs are joining two tables Both SQLs are syntactically correct Query #1 returns about 19614 rows versus Query #2 returns 3550134. Query #1: select * from person.Address addr inner join person.StateProvince prov on addr.StateProvinceID = prov.StateProvinceID Query #2: select * from person.Address addr,person.StateProvince prov
list 100 example of capital used in hospital?
list 100 example of capital used in hospital?
Give an example of a disaster that leads to primary succession and list and explain each...
Give an example of a disaster that leads to primary succession and list and explain each of the steps in the succeeding phases of that succession. How does primary succession differ from secondary succession? What type of succession do we see most commonly associated with clear-cutting of forests?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT