Basic Database, SQL Flashcards

1
Q

What do databases store?

A

data

means of accessing, updating, manipulating, and analyzing data

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

What is SQL?

A

SQL is the standard database language for defining and accessing databses

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

what does a database system consist of?

A
  • data
  • database management software. software that stores and manages data in the database
  • application programs. applications programs that present data and enable the user to interact with the database system
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what does DBMS mean

A

DBMS is database management system

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

Name several database systems

A
MySQL
Oracle (also called Oracle RDBMS)
IBM's DB2 and Informix
Microsoft SQL Server
Sybase
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a database?

A

a database is a collection of tables

a database is a repository of data that form information

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

Who are database management systems designed for?

A

programmers, not users.

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

how do ordinary users access and update basebases?

A

Application programs are built on top of the DBMS for customers to access and update the database

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

How should we think about application programs?

A

a database application program is an interface between the database system and its users

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

what kind of database are most databases?

A

most databases are relational databases

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

what is a relational database. name 3 key components

A

databases based on the relational model.

  1. structure
  2. integrity
  3. language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

define “structure” for relational databases

A

the representation of data

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

define “integrity” for relational databases

A

imposed constraints on the data

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

define “language” for relational databases

A

the means for accessing and manipulating data

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

what is a “relation” in a relational database

A

a relation is a table that consists of nonduplicate rows.

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

what is a record in a database?

A

row

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

what does a column in a relational database represent?

A

the value of a single attribute

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

for relational database theory, what is a row called?

A

tuple

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

for relational database theory, what is a column called?

A

attribute

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

what do tables in a database do?

A

tables describe the relationship among data

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

name 3 types of constraints

A

domain constraints

primary key constraints (intrarelational constraints– a constraint only involves one relation)

foreign key contraints (interrelational– a constraint involves more than one relation)

22
Q

what is an integrity constraint, and why do we use it?

A

imposes a condition that all the legal values in a table must satisfy.

23
Q

define domain constraints

A
  • specify permissible values for an attribute
  • domains can be specified using standard datatypes (such as ints, floating-point numbers, fixed-length stings, variant-length strings, etc).
  • can impose to narrow ranges, for instance. maybe numberOfCredits field can only be between 1 and 5
24
Q

define primary key constraint

A

jjdkd

25
Q

define superkey

A

an attribute or set of attributes that uniquely identifies the relation. distinct set of tuples (rows).

a superkey is a combination of columns that uniquely identifies any row within a relational database management system table.

customer information:

customer name
customer id
social security number
address
date of birth

we extract a set of columns that guarantee to uniquely identify each customer: superkeys

name, SSN, birthday

ID, name, SSN

26
Q

define key

A

a key is a field, or combination of fields, in a database table used to retrieve and sort rows in the table based on certain requirements. Keys are defined to speed up access to data and, in many cases, to create links between different tables.

27
Q

define primary key

A

a candidate key designed by the database designer. often used to identify tuples in a relation (for example, courseId may be a primary key in a Course table).

a table can only have 1 primary key

primary keys enforce entity integrity

28
Q

define candidate key

A

a candidate key is a column, or set of columns, in a table that can uniquely identify any database record without referring to any other data. Each table may have one or more candidate keys. Each can qualify for primary key (though there can only be one primary key).

29
Q

define foreign key

A

a foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. it acts as a cross-reference between tables because it references the primary key of another table, thereby establishing a link between them. technopedia

must be very careful with foreign keys. careless deletion or insertion may destroy the relationship between two tables. see list of bad things on technopedia

foreign keys maintain referential integrity, creating an association between two tables

Two conditions must be met if a set of attributes FK is a foreign key in a relation R that references relation T if it satisfies the following 2 rules

  1. the attributes in FK have the same domain as the primary key in T
  2. a nonnull value on FK in R must match a primary key value in T
30
Q

what is the difference between a candidate key and a primary key

A

candidate keys can qualify to be a primary key. but the database designer should choose the best one to make a primary key.

maybe we have produceId, productNumber, and productName. which should be the primary?

tips:

nothing that can be null

unique, does not repeat

stable, does not change

ProductID is best

31
Q

What do all relational database systems support? where is there some variation? give example

A

primary key constraints
foreign key constraints

do not necessarily support:
domain constraints
microsoft access does not support. so, numberOfCredits range 0-5 cannot be in Access

32
Q

what enforces integrity constraints?

A

the database management system, DBMS

33
Q

what is SQL

A

Structured Language Query

the language for defining tables and integrity constraints and for accessing and manipulating data

it is a universal language for accessing relational database systems

34
Q

what do application programs do?

A

allows users to access a database without directly using SQL, but the applications themselves must use SQL to access the database.

35
Q

Do all relational database systems support all SQL features?

A

no. and some systems have their own extensions.

36
Q

what math provides the theoretical underpining for SQL

A

relational algebra
tuple relational calculus

**text notes: familiarity with these languages will give you a better understanding of database systems and the SQL language

37
Q

what is a domain

A

the set of possible values for a given attribute, and can be considered a constraint on the value of the attribute

38
Q

what is information

A

information is an interpretation of data

39
Q

what do database schemas do

A

describe the relationships, structures, and constraints of the data in the database

40
Q

name the three parts of the three-schema architecture for relational databases

A
  1. internal schema
  2. logical schema
  3. external schema
41
Q

what is an internal schema

A

an internal schema describes how data is stored internally in the database

42
Q

what is a logical schema

A

presents a logical view of the data

43
Q

what is an external schema

A

presents part of the database that is interesting to the users

44
Q

what is MySQL

A

Most widely used open source relational database management system that runs a server providing multi-user access to a number of databases

GNU public license

45
Q

what is LAMP

A

LAMP is an open source web application software stack

Linux, Apache, MySQL, Perl/PHP/Python

46
Q

Name some applications that use MySQL

A

Joomla, WordPress, Drupal, Wikipedia, Facebook, Twitter, YouTube, Flickr

47
Q

MySQL is a RDBMS, and it doesn’t ship with GUI tools to administer MySQL databases or manage data contained within the database. How do we use it?

A

We use command line tools

or

we use “front-ends” (desktop software and web applications that create and manage MySQL databases

48
Q

What is the official front-end tool for MySQL?

A

MySQL Workbench, developed by Oracle.

49
Q

How do we access a MySQL database with Java?

A

JDBC driver for Java

50
Q

what programming languages is SQL most like

A

declarative language, some procedural elements

(describes logic of a computation without describing its control flow. minimizes side effects by describing WHAT the program should do, not how. how gets done at program implementation.

HTML is an example. describes what should appear on a webpage. does not specify the possible interactions with it)