CA Week 12 Notes

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/68

flashcard set

Earn XP

Description and Tags

Databases

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

69 Terms

1
New cards

Database Examples

  • When we think of databases, we often think of tables of information:

    • iTunes shows the title, artist, running time in a row

    • Your car’s information is one line in the state’s database of automobile registrations

    • The U.S. is a row in the demography table for the World Factbook's listing of country name, population, etc.

2
New cards
3
New cards

How are databases different from tables of information?

Databases are different because not just data, but data with INFORMATION tied to it (metadata)

4
New cards

Metadata in databases enables…

Content search

5
New cards

Two most important roles in defining metadata

  1. Identifying the type of data: Each different type of value is given a unique tag

  2. Define the affinity of the data: Tages enclose all data that is logically related (how they are associated with each other

6
New cards

____ is a language for Metadata Tags

XML

7
New cards

XML Stands for…

Extensible Markup Language

8
New cards

Information about XML/Extensible Markup Language

  • A tagging scheme

  • No standard tags to learn

  • Tags are created AS needed (not standardized ones like in HTML)

    • A self-describing language

9
New cards

T/F there is a required first line with XML language

TRUE it is:  <?xml version="1.0" encoding="UTF-8"?>

10
New cards

XML: First tag

Root element that encloses all other tags

11
New cards

XML: Element naming

  • NO SPACES in tags!!

  • don’t start with xml or XML

  • No numbers or punctuation

  • Can be alphanumeric with underscores only

12
New cards

XML: Closing Tags

Matched pairs: <tag></tag> or singletons <tag/>

13
New cards

XML: Case Sensitivity

Tags and attributes are case-sensitive

14
New cards

XML: Proper nesting

All tags must be correctly nested

15
New cards

XML: Attribute quoting

Use straight NOT CURLY single or double quotes

16
New cards

XML: White Space

White space is preserved and converted into single space

17
New cards

XML: Comments

take the form <!-- this is a comment -->

18
New cards
<p>Example of XML</p>

Example of XML

Archipelago is made up of islands and every island has a name and an area

19
New cards

Expanding the Use of XML

  • Create a database of two similar items/additional items 

    • Put both sets of information in the file

      • As long as the two sets use the same tags for the common information, they can be combined

  • Extra data is allowed, and additional tags can be created (such as <a_name> to identify which archipelago is being used)

20
New cards

Building on the Initial XML

  • Group sets of information by surrounding them with tags

  • Root element: The tag that encloses all content of the XML file

    • For our islands XML, the <archipelago> tag was the root element

21
New cards

XML Attributes

  • Like HTML tags, XML tags have attributes

    • Must always be set inside straight (not curly) quotation marks

    • Tag attribute values can be enclosed either in paired single or paired double quotes:

  • <entry location ="Hawai'i">Da Poke Shack</entry>

    • Use attributes for additional metadata, not for content

  • Use of attributes is for additional metadata

    • To add data to help us identify what the item is

    • NOT to store content

    • Do not want to put the store name Da Poke Shack inside of the metadata

22
New cards
<p>Showing expanded XML set</p>

Showing expanded XML set

  • Storing two sets of information

  • Can always add on

23
New cards

XML is a flexible way to encode _______

metadata

24
New cards

Three encoding rules of XML

  1. Identification Rule

  2. Affinity Rule

  3. Collection Rule

25
New cards

Identification Rule

Label Data with Tags

  • Allows you to label data with tags consistently

  • you choose the tags, but once you’ve decided you must ALWAYS surround that kind of data with that tag

26
New cards

Affinity Rule

Group data together that references an entity

  • Always group data referencing an entity

    • Enclose a pair of tags all tagged data referring to the same thing

      • Grouping keeps the data together

      • Grouping makes an association of the tagged data items as related to each other as features of the same thing

27
New cards

Collection Rule

Group instances

  • When you have several instances of the same kind of data, enclosing them in tags

    • Keeps them together and implies that they are instances of the same type

28
New cards

The XML Tree Rules

Produces XML encodings of information produce hierarchical descriptions

  • Can be thought of as trees

  • The hierarchy is a consequence of how the tags enclose one another in data

29
New cards

Visual of the XML Tree

knowt flashcard image
30
New cards

Database tables

Any group of things with common characteristics that specifically identify each one

  • Contain a set of things with common attributes

  • See visual

<p>Any group of things with common characteristics that specifically identify each one</p><ul><li><p>Contain a set of things with common attributes</p></li><li><p>See visual</p></li></ul><p></p>
31
New cards

Database Table Vocab: Entities

Rows of the database table

32
New cards

Database Table Vocab: Attribute Name

Column heading

33
New cards

Database Table Vocab: Entity Instance

Value in a row

34
New cards

Database Table Vocab: Table Instance

the whole table

35
New cards

Things to know about Database tables

  • Rows are all different — attributes uniquely identify each one

  • Even when we don’t know the data for an attribute value it is still a characteristic

  • Rows and columns can be in any order

  • Rearranging the rows or columns will result in the same table

    • All of the same data is still there

  • If we add (or remove) rows or change values, we create a new table instance (new table)

  • Two rows can have the same value for some attributes, but NOT ALL attributes

    • You cannot have two IDENTICAL rows

36
New cards

More information about entities and attributes

  • Entity: Anything defined by a specific set of attributes

  • A table exists with a name and column headings, even with no data (an “empty instance”)

  • Entities have data types which define the form of the information stored as an attribute value (number, text, image, etc.)

  • Entities (rows) are differentiated data of databases, each one able to be told apart from the others by the difference in their attributes
    (column values)

37
New cards

Relations vs. Data Base Tables

Tables are technically called relations, but we’ll call them database tables (so they are the same thing)

38
New cards

Database table rules

  • Rows MUST always be different, even after adding rows

    • No perfect duplicates

  • Be sure the table has all of the attributes (columns) needed to tell the entities apart

  • You can always add a sequence number to guarantee every row is different

    • AKA an ID

39
New cards

Keys

  • By itself, repeated data in a column is not a problem

  • We are interested in columns in which all of the entries are always different to uniquely identify an entity

    • Such a column is called a candidate key

    • Doesn’t have to be just one column (it can be multiple columns together)

40
New cards

Primary Key

 A candidate key that the computer and user agree will used to locate unique entries during database operations

41
New cards

Database scheme definition

the database table’s metadata

42
New cards

Information about the database scheme

  • Succinctly describes a database table

  • Attributes are listed, one per row

  • For each attribute, the user specifies its data type and whether or not it is the primary key 

  • Customary to include a brief description

43
New cards
<p>Database and its scheme visual</p>

Database and its scheme visual

Top is the scheme and the bottom is what the scheme is describing in the table

44
New cards

To get information from database tables, we write a _____ to describe what we want

query

45
New cards

Query Definition

command that tells the database system how to manipulate its tables to compute the answer

  • The answer will be in the form of another database table

46
New cards

Six Query Operations

  1. Project (pronounced like projector)

  2. Select

  3. Cross-Product

  4. Union

  5. Difference 

  6. Join

47
New cards

Project

Picks out and arranges columns from one database table to create a new, possibly “narrower”, table

48
New cards

Select

Picks out rows according to specified criteria

49
New cards

Cross-Product Operation

combines two tables in a process like multiplication

  • For each row in the first table, we make a new row by appending a row from the second table

  • All combinations are in the result

50
New cards

Union

  •  Combines two tables with compatible attributes (same columns)

    • The result has rows from both tables

    • For any rows that are in both table, only one copy is included in the result

51
New cards

Difference

Contains the rows of the first table that are not also in the second (OPPOSITE of a Union)

52
New cards

Join

A combination of a cross product followed by a select operation

  • Takes two database tables, and an attribute from each one (D1.a1 and D2.a2)

  • Crosses the two tables and then uses Select to find those rows of the cross in which the two attributes match: where D1.a1 = D2.a2

  • Puts tables together while matching up related data

53
New cards

SQL definition & stands for

The Language of Databases, stands for Structured Query Language

54
New cards

SQL Information

  • The operations we call Project and Select are combined into one command called select

    • Uses WHERE you specify the formula

  • SQL uses INNER JOIN rather than JOIN because it has several variations for joining data

55
New cards

In SQL * means

everything

56
New cards

What does Select * FROM Customers mean?

Select everything in the customers table

57
New cards

SELECT customer_id, first_name, last name FROM Customers; gives us…

A smaller version of the customers table, it is not EVERYTHING that is in the table

58
New cards

SELECT customer_id, first_name, last name FROM Customers

where customer_id>3

further reduces the table that is outputted because now the value in the customer id instance must be greater than 3

59
New cards

Cross Product

  • Combines two tables in a process like multiplication

    • For each row in the first table, we make a new row by appending a row form the second table

    • All combinations are in the result

60
New cards
<p>Visual of cross-product/cross join, other side tells you code on how to make it</p>

Visual of cross-product/cross join, other side tells you code on how to make it

  • CREATE TABLE Meals (mealName varchar(255));

    • Run SQL

  • CREATE TABLE Drinks (drinkName varchar(255));

    • Run SQL

  • INSERT INTO Drinks VALUES (“tea”);

    • Run SQL

  • INSERT INTO Drinks VALUES (“orange juice”);

    • KEEP RUNNING SQL AFTER EACH COMMAND

  • INSERT INTO Meals VALUES (“sausage”);

  • INSERT INTO Meals VALUES (“eggs”);

  • SELECT * Meals

  • CROSS JOIN Drinks

61
New cards

In order to do a union there must be…

Compatible attributes (like same column names)

  • visual: note that the clients and customers tables have the same column headings

<p>Compatible attributes (like same column names)</p><ul><li><p>visual: note that the clients and customers tables have the same column headings</p></li></ul><p></p>
62
New cards

Join: A Cross-Product followed by a Select operation

  • Takes two database tables, and an attribute from each one (D1.a1 and D2.a2)

  • Crosses the two tables and then uses Select to find those rows of the cross in which the two attributes match: where D1.a1 = D2.a2

  • Puts tables together while matching up related data

OTHER SIDE IS VISUAL!!

knowt flashcard image
63
New cards

Two forms of tables

  1. Physical database

  2. Logical database

64
New cards

Physical database definition

stored on the disk drives of computer systems and is the permanent repository of the database

65
New cards

Physical database infromation

  • Designed by database administrators

  • Data must be accessed fast

  • Set up to avoid redundancy (duplicate information)

    • Only one copy of each piece of stored data

  • Want to make sure that there are not duplicates

66
New cards

Logical database definition

known as the view of the database, created for users on-the-fly, customized for their needs

67
New cards

Logical database information

  • Like what we see on the SQL website

  • Shows different users the customized view of the

  • information they need and want

    • What we need when we need it 

  • Doesn’t exist permanently, but is created every time they need it

  • Retrieved from the one copy stored in the physical database, and provided to the users as needed

  • Creating a new copy each time is essential

    • If it were to be created once and then stored on the user’s computer, then there would be two copies of the information, and they would get out of sync

68
New cards

Review on Queries

  • Specifications using the five operations and Join to define a table from other tables

  • Written in Structured Query Language (SQL)

    • SQL allows a new query to be run each time it is selected or opened, with updated data as input connecting the logical database to the physical one

69
New cards

Summary of Information!!

  • XML tags are an effective way to record metadata in a file

  • Metadata is used to identify values; it can capture the affinity among values of the same entity, and can collect a group of entity instances

  • Database tables have names and fields that describe the attributes of the entities contained in the table

  • Logical databases (database views) are useful windows into physical databases