0% found this document useful (0 votes)
42 views

Department and Dept - Locations Table and

1. The document describes how to create a relationship between two tables in a database called Department and Dept_Locations by creating the tables, defining fields and constraints, and inserting sample data. 2. A primary key is added to the DepNo field in both tables to create a relationship between them and enforce referential integrity. 3. Upon trying to insert a record into Dept_Locations with DepNo=3, the system wouldn't allow it since there is no matching DepNo in the Department table.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Department and Dept - Locations Table and

1. The document describes how to create a relationship between two tables in a database called Department and Dept_Locations by creating the tables, defining fields and constraints, and inserting sample data. 2. A primary key is added to the DepNo field in both tables to create a relationship between them and enforce referential integrity. 3. Upon trying to insert a record into Dept_Locations with DepNo=3, the system wouldn't allow it since there is no matching DepNo in the Department table.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

ACCESS PRACTICAL

Create Tables and Insert Data 8. Create relationship between the two
tables.
We are going to create a relation database a. Click Relationships under the Tool
according to the logical schema below. But
menu
to save time, we will just create the
Department and Dept_Locations table and b. Select the two tables, click Add,
their relationship. and then Close
c. Select DepNo in the
1. Double-click Create table in Design Dept_Locations table, hold the
view
mouse left key, drag it onto the
2. Type DName as the Field Name, and DepNo in the Department table,
choose Text as the Data Type and release the left key.
d. Check Enforce Referential
3. In the General tab Integrity
a. Change Field Size to 15
e. Check Cascade Delete Related
b. Select Yes for Required
(Not Null) Records
c. Select Yes (No Duplicates) f. Click Create and you should be
for Indexed (Unique) able to the window below

4. Do the similar for the other three


attributes in the Department table
according to the requirements below.

Constra
Attribute Data Type Primary Foreign
int
Department VARCHAR(15) NOT NULL

Name
Department INT NOT NULL
UNIQUE
Number 9. Double-click to open the Department
Manager SSN CHAR(9) NOT NULL table, enter the following records:
Manage Start DATE

Date Table Name: Department

5. Right-click the DepNo field and select DName DepNo MgrSSN MgrDate
Primary Key Manufacture 1 888665555 19-JUN-71
Administratio 2 543216789 04-JAN-99
6. Save the table as Department and close n
the table.
10. Close the Department table and enter
7. Create the dept_locations table similar the following records for Dept_Locations
according the requirements below. table.

Data Prim Table Name: Dept_Locations


Attribute Foreign Constraint
Type ary
Departme DepNo DLocation
nt 1 Houston
Department (DepNo) 1 Chicago
INT NOT NULL
Number ON
2 New York
DELETE
CASCADE 3 Salt Lake City
Department VARCH
AR(15)
NOT NULL
Location
1
The system wont allow you to enter the
last record, why? Ignore the last record and
carry on. Close myfirst.dmb.

You might also like