CIS 145 Test Review

10

Click here to load reader

Transcript of CIS 145 Test Review

Page 1: CIS 145 Test Review

Test 2 ReviewCIS-145

Page 2: CIS 145 Test Review

Relational DatabasesHave more than one table where tables are

related to each otherOne to oneOne to manyMany to many

A combination of fields may be used for the table’s primary key

Page 3: CIS 145 Test Review

One to Many RelationshipsEach table contains data about a specific

subject (customers, loans)Each table on the ‘one’ side has a primary

keyPrimary key of the “one” table is a foreign

key in the many table

Page 4: CIS 145 Test Review

Many to Many RelationshipsTwo tables are related, but can have many

records in each table in commonOne student can attend many courses; one

course can be attended by many studentsImplement a many to many relationship by

creating a pair of one to many relationships with a third tableThird table is often referred to as a “join” or

“junction” tableEntries in the join table point to rows in the

original tables

Page 5: CIS 145 Test Review

Foreign KeyA foreign key points to a record in another

tableForeign key “looks like” the related primary

keySame number of fieldsData types for each field must matchField names don’t matter

Page 6: CIS 145 Test Review

Referential IntegrityMakes sure that the records in related tables

are consistentMust have a customer in the customer table for

an order assigned to that customerAvoids “orphans”

Cannot delete a record or change the primary key in the one table when associated records are in the many table, unless have cascade delete and cascade update enabled

Page 7: CIS 145 Test Review

Editing DataMaking new entries, changing existing

entries, and deleting rows are all affected by referential integrityA customer can be added at any timeMust have a customer before a loan can be

entered and associated with a customer Referential integrity doesn’t require entry into a

foreign keyCan delete a loan at any time, but can only

delete a customer if they don’t have any loans (assuming no cascade delete)

Page 8: CIS 145 Test Review

Cascading ChangesWhen referential integrity is enforced can

choose to include Cascade Update and/or Cascade DeleteCascade update passes changes to the primary

key of the “one” table to the related rows in the “many” table

Cascade delete removes rows from the “many” table when a primary key (row) is deleted from the “one” table

Page 9: CIS 145 Test Review

Relationships WindowWhere relationships between tables are

created and definedRelated fields must have the same data type

Autonumber is related to number field with long integer field size

The one table has a 1 next to it; the many has

a next to it

Page 10: CIS 145 Test Review

Autolookup QueriesUse queries to automatically look up data

from related tablesMust contain the foreign key from the many

tableCan add, change or delete data in the source

tables