SQL database definition

User Generated

qvqqv

Programming

Description

A retail chain owns several stores. Each store, depending on its size and the range of products it stocks, is designated as being either a regional or a local store. Each employee works at a single store. Some employees may manage a store.

Entity-relationship diagram

20130520042746entity.jpg


Please see attached

Entity types

Employee (EmployeeNo, Name)

Store (StoreCode, Type)

Product (ProductCode, Description, Cost)

Additional constraints

c.1 The EmployeeNo attribute of Employee takes a character string value in the range 00000 to 99999.

c.2 The StoreCode attribute of Store takes a character string value in the range 00000 to 99999.

c.3 The Type attribute of Store takes a value of either regional or local store.

c.4 The ProductCode attribute of Product takes a character string value in the range 00000 to 99999. (a) Give the SQL required to create a database that represents the E–R data model for the retail chain given in Figure 1.

In your database definition, you should use:

 

the ‘posted foreign key’ approach to implement the WorksAt and Manages relationships;

SQL domains to implement the additional constraints.

(b) Give the SQL required to modify the database definition you gave as your solution to part (a) to include CHECK constraints that represent the following additional constraints:

Additional constraints

c.5 The manager of a store (represented by an occurrence of the Manages relationship) works at the same store (represented by an occurrence of the WorksAt relationship).

c.6 Regional stores must stock all of the products.


User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Related Tags