Video Store Model
The Video store is composed of ten tables. Some of the tables have been simplified to limit the scope of labs. However, you have two infrastructure tables:
COMMON_LOOKUP
SYSTEM_USER
You need to populate the data in the infrastructure tables before you enter information in the other eight tables that support the Video Store Database. There are three use cases for entering data into the eight tables, the use cases are:
- Entering, changing, and querying the
ITEM
table data. - Entering, changing, and querying member accounts, which inserts data into the
MEMBER
,CONTACT
,ADDRESS
,STREET_ADDRESS
, andTELEPHONE
tables. - Entering, changing, and querying the entry of rentals and rental items in the
RENTAL
andRENTAL_ITEM
tables.
You need to learn how to read the following ERD well enough to find the three use cases. Click on the reduced ERD to see the drawing as a full scale image.
The following describes the infrastructure and video store use cases from the least dependent to the most dependent:
- Infrastructure Rule for
SYSTEM_USER
table:Insert rows into the
SYSTEM_USER
table. When there are no rows in the table, you must insert a row that uses theCOMMON_LOOKUP_ID
value of the first row as both theCREATED_BY
andLAST_UPDATED_BY
values. After inserting at least one row in the table, a subsequent row may be inserted with either theCOMMON_LOOKUP_ID
value of the first row or a subsequent row. That requirement occurs because the foreign key constraints on theCREATED_BY
andLAST_UPDATED_BY
columns requires that you insert a value already found in the list ofCOMMON_LOOKUP_ID
column values. - Infrastructure Rule for
COMMON_LOOKUP
table:Inserting rows into the
COMMON_LOOKUP
table requirers that there must be at least one row in theSYSTEM_USER
table because the foreign key constraints impose the same type of restriction as those in theSYSTEM_USER
table. Therefore, you can only insert a row in theCOMMON_LOOKUP
table after you have insert rows in theSYSTEM_USER
table. - Video Store Rule for
ITEM
table:Inserting rows into the
ITEM
table has two dependencies. They are:- You must have rows in the
SYSTEM_USER
table to find and copy a valid primary key value in theSYSTEM_USER_ID
column, which you can then insert into theCREATED_BY
andLAST_UPDATED_BY
columns as a valid foreign key value. - You must have rows in the
COMMON_LOOKUP
table to find and copy a valid primary key value in theCOMMON_LOOKUP_ID
column, which you can then insert into theMEMBER_TYPE
andCREDIT_CARD_TYPE
columns as valid foreign key values.
- You must have rows in the
- Video Store Rule for
MEMBER
,CONTACT
,ADDRESS
,STREET_ADDRESS
, andTELEPHONE
tables:Inserting rows into the
MEMBER
,CONTACT
,ADDRESS
,STREET_ADDRESS
, andTELEPHONE
tables is a workflow because it has a series ofINSERT
statements that interdependent. Each of the tables individually also has dependencies on both of theSYSTEM_USER
andCOMMON_LOOKUP
infrastructure tables. The interdependent rules are:- You must first insert a row in the
MEMBER
table. You call the.NEXTVAL
pseudocolumn for theMEMBER_S1
sequence value to generate aMEMBER_ID
column value as the primary key column. - After inserting into the
MEMBER
table, you insert a row into theCONTACT
table by using:- The
.NEXTVAL
pseudocolumn for theCONTACT_S1
sequence value to generate aCONTACT_ID
column value as the primary key column value of theCONTACT
table. - The
.CURRVAL
pseudocolumn of theMEMBER_S1
sequence value to generate a MEMBER_ID column value as the foreign key value from theMEMBER
table. - You insert into the
CREATED_BY
andLAST_UPDATED_BY
columns a valid foreign key value derived from theSYSTEM_USER_ID
column of theSYSTEM_USER
table. - You insert into the
CONTACT_TYPE
column a valid foreign key value derived from theCOMMON_LOOKUP_ID
column of theCOMMON_LOOKUP
table.
- The
- After inserting into the
CONTACT
table, you insert a row into either theADDRESS
orTELEPHONE
tables because they both have the same dependencies level in the use case. However, theADDRESS
table has a subsequent dependent table, which is theSTREET_ADDRESS
table. As a rule, you follow the patch with the most dependents. That means you should now insert a row into theADDRESS
table by using:- The
.NEXTVAL
pseudocolumn for theADDRESS_S1
sequence value to generate aADDRESS_ID
column value as the primary key column value of theADDRESS
table. - The
.CURRVAL
pseudocolumn of theCONTACT_S1
sequence value to generate aCONTACT_ID
column value as the foreign key value from theCONTACT
table. - You insert into the
CREATED_BY
andLAST_UPDATED_BY
columns a valid foreign key value derived from theSYSTEM_USER_ID
column of theSYSTEM_USER
table. - You insert into the
CONTACT_TYPE
column a valid foreign key value derived from theCOMMON_LOOKUP_ID
column of theCOMMON_LOOKUP
table.
- The
- After inserting into the
ADDRESS
table, you insert a row into either theSTREET_ADDRESS
table by using:- The
.NEXTVAL
pseudocolumn for theSTREET_ADDRESS_S1
sequence value to generate aSTREET_ADDRESS_ID
column value as the primary key column value of theSTREET_ADDRESS
table. - The
.CURRVAL
pseudocolumn of theADDRESS_S1
sequence value to generate aADDRESS_ID
column value as the foreign key value from theADDRESS
table. - You insert into the
CREATED_BY
andLAST_UPDATED_BY
columns a valid foreign key value derived from theSYSTEM_USER_ID
column of theSYSTEM_USER
table. - You insert into the
CONTACT_TYPE
column a valid foreign key value derived from theCOMMON_LOOKUP_ID
column of theCOMMON_LOOKUP
table.
- The
- After inserting into the
STREET_ADDRESS
table, you insert a row into either theTELEPHONE
table by using:- The
.NEXTVAL
pseudocolumn for theTELEPHONE_S1
sequence value to generate aTELEPHONE_ID
column value as the primary key column value of theTELEPHONE
table. - The
.CURRVAL
pseudocolumn of theCONTACT_S1
sequence value to generate aCONTACT_ID
column value as the foreign key value from theCONTACT
table. - You insert into the
CREATED_BY
andLAST_UPDATED_BY
columns a valid foreign key value derived from theSYSTEM_USER_ID
column of theSYSTEM_USER
table. - You insert into the
CONTACT_TYPE
column a valid foreign key value derived from theCOMMON_LOOKUP_ID
column of theCOMMON_LOOKUP
table.
- The
- You must first insert a row in the
- Video Store Rule for
RENTAL
andRENTAL_ITEM
tables:Inserting rows into the
RENTAL
andRENTAL_ITEM
tables is a workflow because it has a series ofINSERT
statements that interdependent. Each of the tables individually also has dependencies on both of theSYSTEM_USER
andCOMMON_LOOKUP
infrastructure tables. The interdependent rules are:- You must first insert a row in the
RENTAL
table. You call the.NEXTVAL
pseudocolumn for theRENTAL_S1
sequence value to generate aRENTAL_ID
column value as the primary key column.The
RENTAL
table insert requires that you have the following:- You must have rows in the
CONTACT
table to find and copy a valid primary key value in theCONTACT_ID
column, which you can then insert into theCUSTOMER_ID
column as a valid foreign key value. - You must have rows in the
SYSTEM_USER
table to find and copy a valid primary key value in theSYSTEM_USER_ID
column, which you can then insert into theCREATED_BY
andLAST_UPDATED_BY
columns as a valid foreign key value. - You must have rows in the
COMMON_LOOKUP
table to find and copy a valid primary key value in theCOMMON_LOOKUP_ID
column, which you can then insert into theMEMBER_TYPE
andCREDIT_CARD_TYPE
columns as valid foreign key values.
- You must have rows in the
- After inserting into the
RENTAL
table, you insert a row into theRENTAL_ITEM
table by using:- The
.NEXTVAL
pseudocolumn for theRENTAL_ITEM_S1
sequence value to generate aRENTAL_ITEM_ID
column value as the primary key column value of theRENTAL_ITEM
table. - The
.CURRVAL
pseudocolumn of theRENTAL_S1
sequence value to generate aRENTAL_ID
column value as the foreign key value from theRENTAL
table. - You must have rows in the
SYSTEM_USER
table to find and copy a valid primary key value in theSYSTEM_USER_ID
column, which you can then insert into theCREATED_BY
andLAST_UPDATED_BY
columns as a valid foreign key value. - You must have rows in the
COMMON_LOOKUP
table to find and copy a valid primary key value in theCOMMON_LOOKUP_ID
column, which you can then insert into theMEMBER_TYPE
andCREDIT_CARD_TYPE
columns as valid foreign key values.
- The
- You must first insert a row in the