HTHVampire Posted April 27, 2014 Share Posted April 27, 2014 From the tables that I attached, a. Assume Job relation is created. Write the SQL statement that will create the EMP relation (use the structure shown in Table 2) Following is my answer: Create Table EMP (empnum NUMBER(3), lname VARCHAR2(15) CONSTRAINT emp_lname_nn Not Null, fname VARCHAR2(25), mi CHAR(1), hiredate DATE CONSTRAINT emp_hiredate_nn Not Null, enddate DATE, Jobcode CHAR(3), Salary Number(10,2) CONSTRAINT emp_empnum_pk Primary Key (empnum), CONSTRAINT emp_jobcode_fk Foreign Key (jobcode) REFERENCES Job(job_code); b. Write the SQL statement that will enter the first data row into the EMP relation My answer: Insert into EMP values (101, 'O''Connel', 'John', 'mi', '11-Aug-2000', NULL, '502', 3600) For both of this questions, can someone checks with me whether am I doing it correctly? Please point out my mistakes if any, I appreciate your guides.Thank you! Link to comment Share on other sites More sharing options...
justsomeguy Posted April 29, 2014 Share Posted April 29, 2014 Is this for MySQL? I haven't seen CONSTRAINT used when setting a field as not allowing null values. Maybe you're using something other than MySQL though. Your insert query is fine, although you missed one of the values. Link to comment Share on other sites More sharing options...
davej Posted April 29, 2014 Share Posted April 29, 2014 Looks like Oracle. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now