Given the metadata above for columns of the Customer, Invoice & Line tables, wri
ID: 3848786 • Letter: G
Question
Given the metadata above for columns of the Customer, Invoice & Line tables, write CREATE TABLE statements for these tables incl PK, FK & CHECK constraints
PKT Column Datatype Size Decimal Domain FK? Positions NUM Numeric CUS CUSTOMER INVOICE CUS LNAME Character 1.35 CUS FNAME Character 1- 35 1 CUS INITIAL Character CUS AREACODE Numeric 3 o 2 100 & s 999 CUS PHONE Numeric 7 1010000 CUS BALANCE 20.00 z 1010000 INVOICE, LINE INV NUMBER LINE Date INV DATE 2 0 21 LINE NUMBER Numeric LINE 5 0 21 LINE UNITS Numeric 6 2 O LINE PRICE NumericExplanation / Answer
Query in oracle:
Customer table:
create table customer (CUS_NUM number(8) primary key,CUS_LNAME varchar2(35),CUS_FNAME varchar2(35),CUS_INITIAL varchar2(1),CUS_AREACODE number(3) check(CUS_AREACODE >=100 and CUS_AREACODE <=999),CUS_PHONE number(7) check(CUS_PHONE>=1010000),CUS_BALANCE decimal(7,2) check(CUS_BALANCE>=0.00),constraint fk_cust foreign key(CUS_NUM) references invoice(INV_NUMBER));
Invoice table:
create table invoice(INV_NUMBER number(7) check(INV_NUMBER>=1010000) primary key,INV_DATE date,constraint fk_invoice foreign key(INV_NUMBER) references line(LINE_NUMBER));
Line table:
create table line(LINE_NUMBER number(2) check(LINE_NUMBER>=1) primary key,LINE_UNITS number(5) check(LINE_UNITS>=1),LINE_PRICE decimal(6,2) check(LINE_UNITS>0));
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.