Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create CUSTOMER table and create table that will link customer to their ice crea

ID: 3814328 • Letter: C

Question

Create CUSTOMER table and create table that will link customer to their ice cream preferences. Make sure to include appropriate primary and foreign keys. You can use customer_id and Ice_ceam id to link customer to flavors

How do I link these table together?

What is the primary key?

What is the foreign key?

INGREDIENT TABLE

Ingredient_id number_(4) primary key,

Ingredient_name char (13),

Cost_per_pint number (6,4));

CUSTOMER TABLE

(CUST_ID NUMBER(2) Primary key,

CUST_NAME CHAR(10),

YEAR_BORN NUMBER(4));

New table should include

Cust_id

Ingredient_name

Name

Flavor preferences (Flavor_ID)

Harry, T

201, 506

Sally, P

406,201,520

Smith, G

101, 201, 510, 520, 406

Name

Flavor preferences (Flavor_ID)

Harry, T

201, 506

Sally, P

406,201,520

Smith, G

101, 201, 510, 520, 406

Explanation / Answer

here you have CUSTOMER TABLE
CUSTOMER TABLE
(CUST_ID NUMBER(2) Primary key,
CUST_NAME CHAR(10),
YEAR_BORN NUMBER(4));

and

INGREDIENT TABLE
Ingredient_id number_(4) primary key,
Ingredient_name char (13),
Cost_per_pint number (6,4));

now we will create a new table which will have customer_id,
ice_cream_id and their name,

CUSTOMER_DESCRIPTION
CUST_ID NUMBER(2) foreign key,
INGREDIENT_ID number(4) foreign key,
INGREDIENT_NAME char(13),
CUST_NAME CHAR(10)


Primary Key
-Primary key is used to identify each row or record in a table.
-a table can have only one primary key.
-primary key cant accept a null value.


Foreign key
-A foreign key is a column (or columns) that references a column (most often the primary key) of another table. The purpose of the foreign key is to ensure referential integrity of the data. In other words, only values that are supposed to appear in the database are permitted.