5
 Robert Wright W0075957 DBAS1100 Relational Theory Lab Due: Wednesday, January 18th 

Relational Theory Lab 1

  • Upload
    robgw

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Relational Theory Lab 1

 

 

Robert Wright

W0075957

DBAS1100

Relational Theory Lab

Due: Wednesday, January 18th 

Page 2: Relational Theory Lab 1

 

DBAS 1100 Lab 1

Relational Theory Lab

Directions: Perform the required components for each section. If you are using

this document, please remember to have a cover page with the lab name and

number, your first and last name, your student number, and the due date of the

lab.

Section 1

In this section of the lab you will look up some definitions and give brief examples.

Questions:

1.  What is an entity? Give some examples. An entity is any physical object

such as a computer or a watch, an event such as a school class or a play, or

a concept such as a customer order.

2.  What is a relationship? Give some examples. A relationship is how entities

are related to one another, like how a student may be related to a course.

3.  What is an attribute? Give some examples. Attributes are things that every

entity has, for example a person can have an attribute of hair length or eye

color.

4.  What is a primary key? A primary key uniquely identifies each record in a

table.

5.  What is a foreign key? A foreign key is a primary key of another table that

is inserted into another table to link the two tables and establish a

relationship between the two tables.

6.  What is entity integrity? Is a rule that states that every table has to have a

primary key that is unique and not null.

7.  What is referential integrity? Requires that every value of a column in one

table exists as a value in another related table.

8.  What is first normal form? It is a set of rules to ensure that a table is strictly

relational. It requires following 5 rules. There must be no top to bottom

ordering to the rows. There must be no left to right ordering to the colums.

Page 3: Relational Theory Lab 1

 

Every row and column intersection has only one value. All columbs must be

regular. And there are no duplicate rows.

9.  What is a view? A view is a stored query that is accessable as a virtual table

in a relational database.

Page 4: Relational Theory Lab 1

 

Section 2

In this section you will user Entity Relationship (ER) diagrams and the crows foot

drawing to connect various tables.

A.  For this exhibit, draw a line with a crows foot to show the relationship that

a consultant does many projects.

CONSULTANT

B.  Draw a new version of the ER diagram in the exhibit below that includes an

associative table called ENROLLMENT to represent the many-to-many

relationship between students and courses.

C.  In the table below, indicate which column(s) should be selected as the

primary key. StudentID should be the primary key

FName LName Phone Birthday StudentId Email

Gord LaRusic 893-

5342

7/29/1863 w0011334 [email protected]

Matt Redmond 899-

9988

8/27/1688 w0123456 [email protected] 

Darlene Redmond 893-

6677

9/12/72 W3334445 [email protected]

PROJECT 

STUDENT COURSE ENROLLMENT

Page 5: Relational Theory Lab 1

 

D.  In the table below, identify the foreign key. INSTRUCTOR$Id is the foreign

key.

E.  In the two tables below, identify an entity integrity violation and a

referential integrity violation. In table STUDENT the ID W009988 is not

unique and the ID field is used as the primary key. In table ENROLLMENT

STUDENT$Id W022112 is not located in the Id field of table STUDENT.

INSTRUCTOR

Id

FName

LName

Office

COURSE 

Code

Title

Credits

INSTRUCTOR$Id

STUDENT

Id FName LName Phone

W009988 Sally Winters 893-8879

W003334 Mike Cameron 309-2223

W009988  Simon Powell 899-9999

ENROLLMENT

STUDENT$Id Course$Code Grade

W009988 OSYS1100 84

W003334 DBAS1100 93

W022112  OSYS1200 75