6. Basic SQL – 4marks Flashcards

1
Q

The schema for SQL questions in 2018 Sem 1 exam will be:

A

DEVICE [dno, dtype, price]
PROVIDER [pno, pname, web]
SERVICE [dno, pno, servicedate]

SERVICE.dno references DEVICE.dno
SERVICE.pno references PROVIDER.pno

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Data in a relational database can be manipulated in the following ways:

A
  • INSERT: New tuples may be inserted
  • DELETE: Existing tuples may be deleted
  • UPDATE: Values of attributes in existing tuples may be changed
  • RETRIEVE: Attributes of specific tuples, entire tuples, or even entire relations may be retrieved

Relational Query Languages should provide all of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Relational Queries are formulated in Relational Query Languages. Three types are:

A
Relational Algebra (RA) 
• Formal query language for a relational database 

Structured Query Language (SQL)
• Implementation of RA
• Comprehensive, commercial query language with widely accepted international standard

Query by Example (QBE)
• Commercial, graphical query language with minimum syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

SQL is designed for:

A
  • data definition,
  • data manipulation, and
  • data control
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

SQL is what type of language?

A

Declarative

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does a declarative language work?

A

Users specify what the result of the query should be, DBMS decides operations and order of execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Relational algebra is a procedural language. How does it work?

A

Algebraic expressions specify an order of operations (ie. how the query will be processed)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

SQL commands can be divided into four subgroups, DDL, DML, DCL, and TCL. Describe the role of the first three:

A

Acronym to remember the three groups: DMC
• Data Definition Language (DDL): Provides commands to create and modify database structure and constraints.
• Data Manipulation Language (DML): Provides commands to insert, delete, update and retrieve
• Data Control Language (DCL): Provides commands to control the access of data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly