Databases and distributed systems Flashcards
(104 cards)
What does SQL stand for?
Structured Query Language
What are the main operations performed by SQL?
- Searching and retrieving records
- Inserting new records
- Deleting records
- Updating existing data
What is the standard language for working with databases?
Structured Query Language (SQL)
What are SQL statements made up of?
Key words, such as CREATE, SELECT, INSERT, UPDATE
How are SQL statements conventionally written for readability?
Key words in capital letters
What is the termination character for SQL statements?
Semicolon (;)
What type of programming language is SQL considered?
Declarative language
What are the five groups of SQL commands?
- Data definition language (DDL)
- Data query language (DQL)
- Data manipulation language (DML)
- Data control language (DCL)
- Data transaction language (DTL)
What is the core syntax to create a table in SQL?
CREATE TABLE tablename (field1 datatype, field2 datatype, …);
What is a primary key in SQL?
A field or set of fields that uniquely identifies a record in a table
What is the convention for naming table names?
Usually singular, e.g., customer, booking, appointment
What is the preferred naming convention for field names?
Clearly define their purpose, often using upper camel case
True or False: SQL is case sensitive.
False
What is a database view?
A virtual table whose contents are the result of a pre-defined query
What is the syntax to create a view in SQL?
CREATE VIEW name AS SELECT field1, field2, … FROM table WHERE condition;
What are the advantages of using database views?
- Security and data protection
- Simplify access to data
- Standardise complex queries
- Track performance metrics
- Saving space
What does DQL stand for?
Data Query Language
What is the basic syntax of a SELECT statement?
SELECT field1, field2,… FROM table;
What does the SELECT * statement do?
Returns all available fields from a table
How can you sort results of a SELECT statement?
By using the ORDER BY clause
What are some common data types used in SQL?
- CHAR
- VARCHAR
- INT
- DECIMAL
- DATE
What is the purpose of the DECIMAL data type?
To store fixed point decimals, allowing for no error
What is the international standard for date formats?
ISO8601
What does a composite primary key consist of?
Multiple fields that together uniquely identify a record