Week 4 - More Java & SQL Intro - Non Access Modifiers and other keywords, variable scope, SQL intro Flashcards
What is data?
Data refers to any piece of information, facts, or statistics that can be recorded and analyzed. In the context of computing, data typically refers to digital information that can be processed by computers and other electronic devices.
Data is information with a purpose. In enterprise applications, data provides aggregated state information for the application. Businesses will use this data for various reasons including, marketing, usage statistics, error reporting, and more. Data is specifically designed to provide insights and persistence information for the applications which they support.
What is a database?
A database is a system of software and capabilities that make validating, storing, searching, filtering, aggregating, grouping, and administering data possible. In enterprise applications databases fall into 2 main categories SQL and NoSQL.
SQL databases
SQL databases are a type of RDBMS that use the standard Structured Query Language to administer the data. Data in a SQL database are started in objects called tables. Tables provide the relational information for the data stored in the database.
NoSQL databases
NoSQL (Not Only SQL) databases are not necessarily a type of RDBMS. NoSQL databases typically use some other means or DSL for administering data and use different structures for storing data and relational information.
Which of the following program copies the databases from one server to another?
mysqlmoveitdb
mysqldbmoveit
mysqlcopydb
mysqldbcopy
mysqldbcopy
To use mysqldbcopy
which privileges are needed at the source server?
SELECT
CREATE
INSERT
UPDATE
SELECT
The program that performs logical backups is _____?
mysqldump
What Does Query Mean?
A query is a request for data or information from a database table or combination of tables. This data may be generated as results returned by Structured Query Language (SQL) or as pictorials, graphs or complex results, e.g., trend analyses from data-mining tools.
Describe an RDBMS
Relational Database Management System or RDBMS is a data storage system based on a relational model where data that is related to a particular object is stored in tables with each entry being represented as a row and each data point is a column in the row that is validated by a set of constraints. The most common type of RDBMS is based on a standard called SQL, however, there are many different implementations (vendors) of the standard each providing a unique set of benefits and features.
RDBMS is a a DBMS that revolves around a relational model
True
An RDBMS manages data by
storing them in tables
A single relational database can contain many tables along with many other types of objects. T/F?
True
Structured Query Language or SQL is…
the standard language for working with RDBM systems. SQL is used to administer and manipulate SQL servers. SQL is a scripting language that is interpreted by the database server.
SQL is used to…
Define database structure
Manipulate stored data
Define data access permissions
Control concurrent data access
Query stored data
DDL
Data Definition Language. Defines data structure
DML
Data Manipulation Language. Insert, Update, Delete record
DCL
Data Control Language. Grant or revoke access permissions to database object
TCL
Transaction Control Language. Defines concurrent operation boundaries
DQL
Data Query Language. Search, filter, group, and aggregate stored data
To accommodate the operations of the above categories, SQL is broken into 5 sublanguages
Each sublanguage is responsible for a specific set of operations on the database
DDL
DML
DCL Data
TCL
DQL
What is the main purpose of SQL?
Administering RDBMS
In a database, each table is defined with a set of
columns
Each column must have a data type which restricts…
the type of data that can be assigned to it
SQL provides a standard list of data types which can be categorized into 3 main categories, name them.
Character types
Numeric types
Temporal types
SQL 3 main categories, each with its own subcategories :
Character types(2)
Numeric types(3)
Temporal types(3)
Character types:
-Fixed-length
-Variable-length
-Numeric types
Decimal:
-Integer
-Floating point
Temporal types:
-Date
-Time
-Timestamp
The purpose of SQL data types is to constraint a column’s expected value. T/F?
True
SQL is used to…
Define database structure
Manipulate stored data
Define data access permissions
Control concurrent data access
Query stored data
6 DDL commands are:
CREATE
ALTER
DROP
TRUNCATE
RENAME
COMMENT
3 DML commands are:
INSERT
UPDATE
DELETE
3 DQL commands are:
SELECT -DCL
GRANT
REVOKE
Data Definition Language is the SQL language subset used for…
defining data or altering structure in the database.
CREATE can be used to create:
objects on the server
Database
User
Table
Index
Trigger
Function
Stored Procedure
View
The DROP command is used to remove
objects from the server
Any object created using the CREATE command can be dropped using…
the DROP command
The ALTER command is used to…
change some characteristics of an object. The command will ultimately be used to add, drop, or modify some options on the object.
The RENAME command is used
to rename objects
The TRUNCATE command is used to remove
all data from a table along with all space allocated for the records.
Difference between truncate and drop command
Unlike DROP truncate will preserve the structure of the table.
The DDL sublanguage is used to ______ in a database.
define data structure
Choose the DDL Commands
Insert, Update, Delete
Grant, Revoke
Commit, Rollback, Savepoint
Create, Drop, Alter, Truncate, Comment, Rename
None of these
Create, Drop, Alter, Truncate, Comment, Rename
The Drop command maintains the structure of the database while removing all data from a table. T/F?
false
The Truncate command removes a table from the database schema. T/F?
False
Syntax to create a table:
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
…..
columnN datatype,
PRIMARY KEY( one or more columns )
);
Define primary key:
The PRIMARY KEY constraint is used to uniquely identify each record in a table.
Primary keys must contain values that are UNIQUE and NOT NULL.
A table can have only a single primary key.
Describe the purpose of schema in a database:
A database schema defines the form of database and the data within it. An RDBMS schema can include objects like tables, triggers, functions, procedures, indexes, and views. In this section we focused on tables. In and RDBMS table the schema defines the columns, their data types, and constraints.
Schema defines a set of.
integrity constraints
templates
normalization rules
none of these
integrity constraints
In MySQL, SCHEMA is synonymous with
DATABASE
Unlike the other sublanguages, DQL is only associated with a single command
SELECT
The DQL sublanguage is used to ______ in a database.
query for data
Which clause is associated with restricting record count?
From table_ref
Where where_condition
Limit count Offset count
None of these
Limit count Offset count
Which clause is associated with filtering records before grouping?
Having having_condition
Where where_condition
Limit limit_condition
None of these
Where where_condition
. Given a data set data = [-8, 1, 0, -2, -3, 7, 5, 4, -6, 6, -9, 10, -4, -10, 3] With a result set [1,2,3,4,5] Choose the select statement that best represents the query.
Select * from data where x>0 and x<6;
Given a data set data = [-8, 1, 0, -2, -3, 7, 5, 4, -6, 6, -9, 10, -4, -10, 3] With a result set [-10, -9, -8, -6, -3, -2] Choose the select statement that best represents the query.
Select * from data where x between 0 and -10 order by x;