Create, read, update, and delete (Create/read/update/delete,crud) operations are the most basic database operations, but they are also the most important operations. CRUD operations are usually done using the Structured Query Language (structured query language,sql) in the relational database system. As the Web becomes more data-oriented, it needs to move from sql-based crud operations to a semantic Web based crud operation. Learn how to use PHP to perform CRUD operations through a semantically based Web. Common abbreviations
api-application Programming Interface (application programming Interface)
crud-Create/read/update/delete (Create/read/update/delete)
http-Hypertext Transfer Protocol (hypertext Transfer Protocol)
mvc-mode-View-controller (Model-view-controller)
oop-object-oriented Programming (object-oriented programming)
rdf-Resource Description Framework (Resource Description Framework)
sparql-simple protocol and RDF query language (easy Protocol and RDF queries Language)
sql-Structured Query Language (structured query Language)
ui-UI (User interface)
w3c-Web Consortium (World Wide website Consortium)
When developing WEB applications, it is a standard practice to create a database structure that places server-side code for the logical and UI tiers. To connect to a database, the server-side code needs to perform some basic creation, update, delete, and-most important-read records, and so on. Because the WEB application's background database is usually a relational database, these CRUD operations are performed using a well-known SQL language. However, as WEB development has increasingly adopted object-oriented programming (OOP), the model has changed.
The Resource Description Framework (Resource Description FRAMEWORK,RDF) is an ideal way to describe an object while preserving the meaning of the data. The simple protocol and the RDF Query language, which is pronounced as "sparkle", is a language commonly used to query against the data, because it matches the structure of the RDF itself in the form of statements Protocol. Both RDF and SPARQL are technologies in the so-called Semantic Web stack (Semantic Web stack).
To thoroughly apply semantic Web concepts, you can use SPARQL to apply traditional Web development technologies to RDF data. This article will show you how to use the simplified schema-view-controller (MODEL-VIEW-CONTROLLER,MVC) design model, PHP server-side scripting language, and SPARQL to connect to rdf-in contrast to using SQL in relational database systems.
SQL and SPARQL CRUD operations
Prerequisites This article assumes that you have a basic understanding of SQL, PHP, and WEB application development. Understanding the semantic Web is also very beneficial. To run the Create, update, and DELETE commands on semantic web based data, you need a semantic Web database that supports the Sparql/update specification.
When using SQL and SPARQL for development, you need to look at the similarities and differences between CRUD operations. Listing 1 shows the SQL code for the read operation.
SELECT realname, DOB, locationfrom usertable WHERE realname = "John Smith";
Compare this sql-based code with the SPARQL based code shown in Listing 2. The reason for using these two read operations is that they are easiest to understand, implement, and explain. This is the same for both SQL and SPARQL.
PREFIX foaf:
When comparing two lists, your first idea is likely to be that the SPARQL version is significantly longer than the SQL version. This is true, but do not mistakenly assume that SQL is inherently simpler and cleaner. Depending on the engine being run, SPARQL can be distributed all through content called linked data results (linked). In addition, it allows for dynamic mode because it has an object-oriented perspective that is linked to each other, and contrasts with a rigorous SQL relational perspective. If you want to separate relational database tables into islands of many data, you actually use a lot more SQL code than SPARQL-not to mention that there are a lot of nasty JOIN descriptors in SQL.
The first two lines of SPARQL are PREFIX declarations. According to the semantic Web theory, everything-whether object or data graph source (also an object)-has a Uniform Resource identifier (uniform Resource Identifier,uri). The PREFIX line simply applies the temporary tag to some URIs-in this case, friend of a friend and RDF schema. The benefit is that you can use the PREFIX declaration in a query later without having to use the full URI.
The next line of the SPARQL code describes the query request. This statement is essentially the same as the SQL statement, with the difference being an additional request to the URI. Note that the question mark is used (?) to indicate that the term is a variable.
The FROM statement describes where to get the data. This is the same in SQL and SPARQL, except that in SPARQL, the data source name is a URI, not a string representing a physical location on the computer or network.
The WHERE statement of the two is completely different, because using SPARQL, you must specify the pattern used to get the data. Similarly, if you try to do this using a relational method, you will need to spend much more than normal SQL: you need to use PHP, Java? A programming language or some other server-side language to perform checks between data sources. The SPARQL code line completes the operation, which includes ensuring that the data being retrieved belongs only to the person type. SPARQL will get the name and location, while performing some pattern matching to find the correct John Smith.
Create
CRUD operations in SPARQL are often more mysterious than read operations. However, these operations can be done. First, the Create operation inserts a new record or object into the table or diagram.
INSERT into Usertable (Realname, DOB, location) VALUES ("John Smith", "1985-01-01", "Bristol, UK");
Now, compare the SQL-based code in Listing 3 with the create operation in the SPARQL-based code in Listing 4.
PREFIX foaf: