Databases - Tables - SQL - Joins/Union Flashcards

1
Q

Table

A

is a unique set of data with a consistent number of typed data attributes, called columns. Each table has a primary key which is a column that uniquely identifies a row.

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

Where is the primary key? parent or child table

A

parent

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

What does the parent key become in the “child” table?

A

A foreign key which is a column

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

Ordinality (aka modality)

A

Represents the parent side of the relationship. It indicates if the relationship between the tables is optional or mandatory/required (i.e. book and book buyer vs. book and writer)

Zero or O means it’s optional

One or more (a perpendicular line) means is required

  1. Zero or More
  2. One or more
  3. One and only one
  4. Zero or one
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Cardinality (aka multiplicity)

A

Describes the “child” side of the relationship. Can be either:

  1. 1 to 1
  2. 1 to many
  3. Many to many

To implement a many to many relationship, there has to be an associative table or a table that acts as the in-between by serving as a lookup/table of contents to link. Without the associative table, it would not be possible to look up a single row in a many to many relationship.

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

Spreadsheets

(namely Excel)

A

A spreadsheet is an electronic ledger, i.e., an electronic version of paper accounting worksheets. It was created to facilitate people who needed to store their accounting information in tabular form digitally.

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

Commonalities between Databases and Spreadsheets

A
  1. Both can contain large amounts of tabular data
  2. Both can use existing data to make calculations
  3. Can be used by many users
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Differences between databases and spreadsheets?

A

The difference between these two forms of data storage lies in the way three characteristics are implemented

1. Data contained

Excel - any type of info in a cell (date, integer, string, etc.). Different values and formats possible for cells.

Database - only raw data, single data value per cell, must preset the type of data contained in the field. Otherwise, you might get errors.

2. Storing Data

Excel - you store data in the cell

Databases- store the data in a table, and no formatting available (font, color, size, etc.). All you care about is to save the numbers.

3. Calculations in cells

Excel - different cells contain calculations (functions and formulas)

Databases - all calculations are done after retrieval, can only view

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

Benefits of Databases over Excel

A
  1. Data intengrity
  2. Not limited to 1M rows of data
  3. Relations between tables are logically limited in Excel, and slows down the program.
  4. Being able to control changes - stable structure and controlling access/user restrictions. Changes are visible to everybody instantly.
  5. Increases efficiency (less duplicates, and easier to update information through related tables)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Entity-relationship (ER) Diagram

A

One is drawing an Entity-Relationship diagram, an ER diagram for short. As shown in the picture below, the different figures represent different data entities and the specific relationships we have between entities.

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

Relational Schema

A

It represents a table in the shape of a rectangle. The name of the table is at the top of the rectangle. The column names are listed below.

All relational schemas in a database form the database schema. You can also see lines indicating how tables are related in the database.

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

Database management

A

Database design + creation + manipulation =

Database management

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

Joins vs Unions

A

Joins and Unions can be used to combine data from one or more tables. The difference lies in how the data is combined

Joins combine data into new columns - matches columns in one with columns in the other

Unions combine data into new rows (might require same number of columns and same data type).

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

DBMS

A

Database management system

Benefit - it creates a separation between the queries from users or other DBMSs from the data stored. The queries communicate with the DBMS

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