Related
I'm creating two tables and I would like to use UserID in User_info_table as a foreign key in the Trail_info_table, but it keeps showing as NULL.
CREATE TABLE CW2.User_info_table
(
UserID int IDENTITY PRIMARY KEY,
User_name varchar(255),
Email_Address varchar(255) NOT NULL,
User_password varchar(255) NOT NULL,
User_access_level int NOT NULL,
);
INSERT INTO CW2.User_info_table (User_name, Email_Address, User_password, User_access_level)
VALUES ('Grace Hopper', 'grace#plymouth.ac.uk', 'ISAD123!', 1)
INSERT INTO CW2.User_info_table (User_name, Email_Address, User_password, User_access_level)
VALUES ('Tim Berners-Lee', 'tim#plymouth.ac.uk', 'COMP2001!', 1)
INSERT INTO CW2.User_info_table (User_name, Email_Address, User_password, User_access_level)
VALUES ('Ada Lovelace', 'ada#plymouth.ac.uk', 'insecurePassword', 1)
CREATE TABLE CW2.Trail_info_table
(
TrailID int IDENTITY,
Trail_name char(255) NOT NULL,
Trail_owner varchar(255),
Trail_owner_ID int
FOREIGN KEY REFERENCES CW2.User_info_table(UserID),
Trail_difficulty int NOT NULL,
Trail_length int NOT NULL,
CONSTRAINT Trail_primary PRIMARY KEY (TrailID),
);
INSERT INTO CW2.Trail_info_table (Trail_name, Trail_owner, Trail_difficulty, Trail_length)
VALUES ('Spring Sprint', 'Grace Hopper', 1, 10)
INSERT INTO CW2.Trail_info_table (Trail_name, Trail_owner, Trail_difficulty, Trail_length)
VALUES ('Summer Stroll', 'Tim Berners-Lee', 2, 15)
INSERT INTO CW2.Trail_info_table (Trail_name, Trail_owner, Trail_difficulty, Trail_length)
VALUES ('Winter Waltz', 'Ada Lovelace', 3, 20)
I tried to get the UserID (1,2,3) in the Trail_owner_ID column as a foreign key but it keeps showing up as NULL
I'm relatively new to SQL. I was wondering how I would go about adding data to my foreign keys. I have gotten errors with everything I've tried and google hasn't been much help... also, please ignore the nonsense data I've added.
Thank you!
Here's what I'm starting with:
CREATE TABLE GAME
(
GAME_ID INT NOT NULL AUTO_INCREMENT,
GAME_NAME VARCHAR(20) NOT NULL,
PLATFORM_ID INT NOT NULL,
PUBLISHER_ID INT NOT NULL,
DEV_ID INT NOT NULL,
GAME_GENRE VARCHAR(20),
PRIMARY KEY(GAME_ID)
);
CREATE TABLE DEVELOPER
(
DEV_ID INT NOT NULL AUTO_INCREMENT,
DEV_NAME VARCHAR(20) NOT NULL,
DEV_CIY VARCHAR(20),
DEV_COUNTRY VARCHAR(20),
DEV_CEO VARCHAR(20),
DEV_GAMES INT,
PRIMARY KEY(DEV_ID)
);
CREATE TABLE PUBLISHER
(
PUBLISHER_ID INT NOT NULL AUTO_INCREMENT,
PUBLISHER_NAME VARCHAR(20) NOT NULL,
DEV_ID INT NOT NULL,
PUBLISHER_CEO VARCHAR(20),
PUBLISHER_GAMES INT,
PUBLISHER_EMPLOYEES INT,
PRIMARY KEY(PUBLISHER_ID)
);
CREATE TABLE EMPLOYEE
(
EMPLOYEE_ID INT NOT NULL AUTO_INCREMENT,
EMPLOYEE_NAME VARCHAR(20) NOT NULL,
EMPLOYEE_ROLE VARCHAR(20) NOT NULL,
DEV_ID INT NOT NULL,
GAME_ID INT NOT NULL,
EMPLOYEE_NUM CHAR(10),
PRIMARY KEY(EMPLOYEE_ID)
);
CREATE TABLE GAMECREDITS
(
GAMECREDITS_ID INT NOT NULL AUTO_INCREMENT,
GAME_ID INT NOT NULL,
PUBLISHER_ID INT NOT NULL,
DEV_ID INT NOT NULL,
GAMECREDITS_YEAR INT,
PLATFORM_ID INT NOT NULL,
PRIMARY KEY(GAMECREDITS_ID)
);
CREATE TABLE PLATFORM
(
PLATFORM_ID INT NOT NULL AUTO_INCREMENT,
PLATFORM_PC BOOLEAN,
GAME_ID INT NOT NULL,
PLATFORM_PRICE NUMERIC,
PLATFORM_XBOOX BOOLEAN,
PLATFORM_SWOOTCH BOOLEAN,
PRIMARY KEY(PLATFORM_ID)
);
ALTER TABLE GAME
ADD FOREIGN KEY (PLATFORM_ID) REFERENCES PLATFORM(PLATFORM_ID),
ADD FOREIGN KEY (PUBLISHER_ID) REFERENCES PUBLISHER(PUBLISHER_ID),
ADD FOREIGN KEY (DEV_ID) REFERENCES DEVELOPER(DEV_ID);
ALTER TABLE PUBLISHER
ADD FOREIGN KEY (DEV_ID) REFERENCES DEVELOPER(DEV_ID);
ALTER TABLE EMPLOYEE
ADD FOREIGN KEY (DEV_ID) REFERENCES DEVELOPER(DEV_ID),
ADD FOREIGN KEY (GAME_ID) REFERENCES GAME(GAME_ID);
ALTER TABLE GAMECREDITS
ADD FOREIGN KEY (GAME_ID) REFERENCES GAME(GAME_ID),
ADD FOREIGN KEY (PUBLISHER_ID) REFERENCES PUBLISHER(PUBLISHER_ID),
ADD FOREIGN KEY (DEV_ID) REFERENCES DEVELOPER(DEV_ID),
ADD FOREIGN KEY (PLATFORM_ID) REFERENCES PLATFORM(PLATFORM_ID);
ALTER TABLE PLATFORM
ADD FOREIGN KEY (GAME_ID) REFERENCES GAME(GAME_ID);
INSERT INTO GAME (GAME_ID, GAME_NAME, GAME_GENRE)
VALUES
(001, 'GTA Sons Andres', 'Sand-Box'),
(002, 'Not Destiny', 'FPS'),
(003, "Red Alive Redemption", 'TPS'),
(004, 'Animal Passing', 'Simulation'),
(005, 'Knights Creed', 'Action'),
(006, 'Simpsins hit and run', 'Action');
INSERT INTO DEVELOPER
(DEV_ID, DEV_NAME, DEV_CITY, DEV_COUNTRY, DEV_CEO, DEV_GAMES)
VALUES
(010, 'Kawcho Games', 'Texas', 'usa', 'Joe Houston', 6),
(020, 'NotStar Games', 'Vancouver', 'canada' 'Sam Haser', 7),
(030, 'Boungie', 'New York', 'usa' 'Pete Larson', 3),
(040, 'Pinnaple Games', 'Halifax', 'canada', 'Sam Haser', 6),
(050, 'Noontendo', 'Toronto', 'canada', 'Bowser Doug', 10),
(060, 'Oobiesoft', 'Washington', 'usa', 'Larry Seinfield', 5);
INSERT INTO PUBLISHER
(PUBLISHER_ID, PUBLISHER_NAME, PUBLISHER_CEO, PUBLISHER_GAMES, PUBLISHER_EMPLOYEES)
VALUES
(111, 'Kawcho Publishing', 'Cassie Haley', 44, 20),
(222, 'Walmort Publishers', 134, 'Perry Plat', 45, 23),
(333, 'Kents Publishing', 156, 'Linda Frend', 23, 15),
(444, 'Coffee House', 145, 'Susy Paige', 45, 15),
(555, 'Off the ground publishing', 189, 'Kerry Doug', 60, 25),
(666, 'yourWay', 1, 'beff, jezos', 46, 25);
INSERT INTO EMPLOYEE
(EMPLOYEE_ID, EMPLOYEE_NAME, EMPLOYEE_ROLE)
VALUES
(100, 'Fiacre Julen', 'Ui design'),
(200, 'Sebastian Aneta', 'Animator'),
(300, 'Xavia Guy', 'Developer'),
(400, 'Oakley Jillie', 'Character Design'),
(500, 'Keaton Lula', 'Marketing'),
(600, 'Liv Randell', 'Developer');
INSERT INTO GAMECREDITS
(GAMECREDITS_ID, GAMECREDITS_YEAR)
VALUES
(101, 2012),
(102, 2020),
(103, 1999),
(104, 2015),
(105, 2017),
(106, 2019);
INSERT INTO PLATFORM
(PLATFORM_ID, PLATFORM_PC, PLATFORM_PRICE, PLATFORM_XBOOX, PLATFORM_SWOOTCH);
VALUES
(123, FALSE, 49.99, TRUE, FALSE),
(145, TRUE, 25.00, FALSE, FALSE),
(167, TRUE 26.99, FALSE, FALSE),
(189, FALSE, 12.49, FALSE, TRUE),
(134, FALSE, 69.99, FALSE, TRUE),
(156, FALSE, 36.00, TRUE, FALSE);
I appreciate any help I can get as this is relating to a final assignment of mine. The only solutions I've found through google and my teacher would take up like 60 update queries to fill in my tables.
Give me any advice you can :)
Using Postgres and setting up my schema in an SQL file for an app I am building. I have tables: users, posts, templates and a junction table users_posts_templates.
Users is 1:N with Posts
Users is also 1:N with Templates
users_posts_templates is meant to act as a junction so that a Post owned by a User can have N templates from any and all Users, my schema is set up as such:
CREATE TABLE users (
username VARCHAR(30) UNIQUE PRIMARY KEY,
first_name VARCHAR(30) NOT NULL,
last_name VARCHAR(30) NOT NULL,
password TEXT NOT NULL,
email TEXT NOT NULL
CHECK (position('#' IN email) > 1),
address TEXT NOT NULL,
is_admin BOOLEAN NOT NULL DEFAULT FALSE
);
-- CREATE TYPE category AS ENUM ('environment', 'health care', 'defense');
-- CREATE TYPE states AS ENUM ('USA', 'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FM', 'FL', 'GA', 'GU', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MH', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PW', 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VI', 'VA', 'WA', 'WV', 'WI', 'WY');
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
link TEXT,
body TEXT NOT NULL,
username VARCHAR(30) NOT NULL
FOREIGN KEY REFERENCES users(username) ON DELETE CASCADE,
tag category NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
location states NOT NULL
)
CREATE TABLE templates (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
body TEXT NOT NULL,
)
CREATE TABLE users_posts_templates (
post_id INTEGER NOT NULL
FOREIGN KEY REFERENCES posts(id) ON DELETE CASCADE,
username VARCHAR(30) NOT NULL
FOREIGN KEY REFERENCES users(username) ON DELETE CASCADE,
template_id INTEGER NOT NULL
FOREIGN KEY REFERENCES templates(id) ON DELETE CASCADE,
PRIMARY KEY (username, post_id, template_id)
)
I get the error when I build ERROR: relation "users" already exists
How do I set up my relationships so that the Posts table and junction table can both reference Users or is there a better approach I should consider?
Which version of PostgreSQL you are using? I tested on the Postgre 13 and Postgre 14 this script, no error, all tables and foreign keys were created.
CREATE TABLE users (
username VARCHAR(30) UNIQUE PRIMARY KEY,
first_name VARCHAR(30) NOT NULL,
last_name VARCHAR(30) NOT NULL,
password TEXT NOT NULL,
email TEXT NOT NULL
CHECK (position('#' IN email) > 1),
address TEXT NOT NULL,
is_admin BOOLEAN NOT NULL DEFAULT FALSE
);
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
link TEXT,
body TEXT NOT NULL,
username VARCHAR(30) NOT null
REFERENCES users(username) ON DELETE CASCADE,
tag text NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE templates (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
body TEXT NOT NULL
);
CREATE TABLE users_posts_templates (
post_id INTEGER NOT NULL
REFERENCES posts(id) ON DELETE CASCADE,
username VARCHAR(30) NOT NULL
REFERENCES users(username) ON DELETE CASCADE,
template_id INTEGER NOT NULL
REFERENCES templates(id) ON DELETE CASCADE,
PRIMARY KEY (username, post_id, template_id)
);
I do not know your business logic, so maybe I am thinking incorrectly. I think the username field in the users_posts_templates table is unnecessary. Because if we need it, we can get it from the posts table using users_posts_templates.post_id
create table STAFF
(
StaffID TINYINT IDENTITY NOT NULL,
StaffName varchar(20) NOT NULL,
Phone varchar(10) NOT NULL,
Gender char(01),
DoB date NOT NULL,
Mentor TINYINT,
Payment_ID TINYINT NOT NULL,
constraint staff_pk primary key (StaffID),
constraint staff_fk
foreign key (Payment_ID) references PAYMENT(Payment_ID),
constraint mentor_fk
foreign key (Mentor) references staff(StaffID)
);
Table was created successfully. But when I'm going to insert values like this:
insert into STAFF
values ('Adeesha', '077282018', 'M', '1997-11-30', '', '5'),
('Kavitha', '0772556899', 'F', '1956-11-28', '', '4'),
('Patee Aiya', '0775669844', 'M', '1954-01-04', '', '3'),
('Chanuka', '0772562984', 'M', '1997-02-24', '', '2'),
('Umesha', '0723328284', 'F', '1997-11-26', '', '3');
I get the following error:
Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted with the FOREIGN KEY SAME TABLE constraint "mentor_fk".
The conflict occurred in database "F_T", table "dbo.STAFF", column 'StaffID'.
An empty string ('') is not the same as NULL. You should use NULL:
insert into STAFF(StaffName, Phone, Gender, DoB, Mentor, Payment_ID)
values ('Adeesha', '077282018', 'M', '1997-11-30', NULL, 5),
('Kavitha', '0772556899', 'F', '1956-11-28', NULL, 4),
('Patee Aiya', '0775669844', 'M', '1954-01-04', NULL, 3),
('Chanuka', '0772562984', 'M', '1997-02-24', NULL, 2),
('Umesha', '0723328284', 'F', '1997-11-26', NULL, 3);
Notes:
When using insert, list all the columns being inserted into the table. This is a best-practice.
Do not insert into the identity column. It is generated automatically.
Use NULL to mean NULL rather than an empty string. They are not the same.
If a value is a number, do not enclose it in single quotes.
I have created my tables as shown below (I am using Oracle XE). The problem that occurs is that when I try to insert values into the tables, I get an error because the value of one's foreign key, has not been entered as a primary key of the other. For example, see tables DEPARTMENT and EMPLOYEE. Below, along with table creation code, is also the data inserting part. How to bypass that problem?
CREATE TABLE DEPARTMENT
(
DNAME VARCHAR(10),
DEPTID INTEGER NOT NULL,
MNG_IDNO INTEGER NOT NULL,
PRIMARY KEY (DEPTID)
);
CREATE TABLE EMPLOYEE
(
IDNO INTEGER NOT NULL,
FNAME VARCHAR(10) NOT NULL,
LNAME VARCHAR(10) NOT NULL,
GENDER VARCHAR(6) NOT NULL,
CITY VARCHAR(20),
AREA VARCHAR(20),
STREET VARCHAR(50),
HOUSENO VARCHAR(4),
ZIPCODE INTEGER,
BIRTHDAY DATE,
SALARY INTEGER,
IBAN VARCHAR(34),
DEPT_ID INTEGER NOT NULL,
PRIMARY KEY (IDNO)
);
CREATE TABLE CUSTOMER
(
IDNO INTEGER NOT NULL,
FNAME VARCHAR(10) NOT NULL,
LNAME VARCHAR(10) NOT NULL,
GENDER VARCHAR(6) NOT NULL,
CITY VARCHAR(20),
AREA VARCHAR(20),
STREET VARCHAR(50),
HOUSENO VARCHAR(4),
ZIPCODE INTEGER,
BIRTHDAY DATE,
PRIMARY KEY (IDNO)
);
CREATE TABLE CAR
(
VIN INTEGER NOT NULL,
BRAND VARCHAR(10) NOT NULL,
MODEL VARCHAR(10) NOT NULL,
COLOR VARCHAR(10) NOT NULL,
TRANTYPE VARCHAR(10) NOT NULL,
FUELTYPE VARCHAR(10) NOT NULL,
ENGCC INTEGER NOT NULL,
ENTRYDATE DATE,
PRICE INTEGER NOT NULL,
PAYMENTMETHOD VARCHAR(10) NOT NULL,
DEPT_ID INTEGER NOT NULL,
CUST_IDNO INTEGER NOT NULL,
PRIMARY KEY (VIN)
);
CREATE TABLE CAR_PARTS
(
PARTNUM VARCHAR(25) NOT NULL,
PARTNAME VARCHAR(25) NOT NULL,
COST INTEGER NOT NULL,
PRIMARY KEY (PARTNUM)
);
CREATE TABLE USED_CAR
(
CAR_VIN INTEGER NOT NULL,
MILEAGE INTEGER NOT NULL,
REGDATE DATE NOT NULL,
PRIMARY KEY (CAR_VIN)
);
CREATE TABLE SERVICE
(
DUE_DATE DATE,
ARR_DATE DATE,
COST INTEGER NOT NULL,
SERVICE_NUM INTEGER NOT NULL,
CUST_IDNO INTEGER NOT NULL,
PAYMENTMETHOD VARCHAR(10) NOT NULL,
CAR_VIN INTEGER NOT NULL,
PRIMARY KEY (SERVICE_NUM)
);
CREATE TABLE CUST_PHONUMBER
(
PHONE_NUM INTEGER NOT NULL,
CUST_IDNO INTEGER NOT NULL,
PHONE_TYPE VARCHAR(10),
PRIMARY KEY (CUST_IDNO, PHONE_NUM)
);
CREATE TABLE CAR_DEFECTS
(
DEFECTS VARCHAR(100) NOT NULL,
CAR_VIN VARCHAR(100) NOT NULL,
PRIMARY KEY (DEFECTS, CAR_VIN)
);
CREATE TABLE EMPLOYEE_PHONUMBER
(
PHONENUM INTEGER NOT NULL,
EMPL_IDNO INTEGER NOT NULL,
PRIMARY KEY (PHONENUM, EMPL_IDNO)
);
CREATE TABLE SERVICE_DETAILS
(
SERVICENUM INTEGER NOT NULL,
PROBLEMS VARCHAR(100) NOT NULL,
SOLUTION VARCHAR(100),
PRIMARY KEY (PROBLEMS, SERVICENUM)
);
CREATE TABLE HAS
(
PART_NUM VARCHAR(25) NOT NULL,
CAR_VIN INTEGER NOT NULL,
PRIMARY KEY (PART_NUM, CAR_VIN)
);
CREATE TABLE USES
(
PART_NUM VARCHAR(25) NOT NULL,
SERVICE_NUM INTEGER NOT NULL,
PRIMARY KEY (PART_NUM, SERVICE_NUM)
);
ALTER TABLE DEPARTMENT ADD FOREIGN KEY (MNG_IDNO) REFERENCES EMPLOYEE(IDNO);
ALTER TABLE EMPLOYEE ADD FOREIGN KEY (DEPT_ID) REFERENCES DEPARTMENT(DEPTID);
ALTER TABLE CAR ADD FOREIGN KEY (DEPT_ID) REFERENCES DEPARTMENT(DEPTID);
ALTER TABLE CAR ADD FOREIGN KEY (CUST_IDNO) REFERENCES CUSTOMER(IDNO);
ALTER TABLE SERVICE ADD FOREIGN KEY (CUST_IDNO) REFERENCES CUSTOMER(IDNO);
ALTER TABLE SERVICE ADD FOREIGN KEY (CAR_VIN) REFERENCES CAR(VIN);
ALTER TABLE USED_CAR ADD FOREIGN KEY (CAR_VIN) REFERENCES CAR(VIN);
ALTER TABLE HAS ADD FOREIGN KEY (PART_NUM) REFERENCES CAR_PARTS(PARTNUM);
ALTER TABLE HAS ADD FOREIGN KEY (CAR_VIN) REFERENCES CAR(VIN);
ALTER TABLE USES ADD FOREIGN KEY (PART_NUM) REFERENCES CAR_PARTS(PARTNUM);
ALTER TABLE USES ADD FOREIGN KEY (SERVICE_NUM) REFERENCES SERVICE(SERVICE_NUM);
ALTER TABLE CUSTOMER_PHONUMBER ADD FOREIGN KEY (CUST_IDNO) REFERENCES CUSTOMER(IDNO);
ALTER TABLE EMPLOYEE_PHONUMBER ADD FOREIGN KEY (EMPL_IDNO) REFERENCES EMPLOYEE(IDNO);
ALTER TABLE SERVICE_DETAILS ADD FOREIGN KEY (SERVICENUM) REFERENCES SERVICE(SERVICE_NUM);
Data Insert:
INSERT INTO EMPLOYEE VALUES (1234,'ANTREAS','GEORGIOU','MALE','NICOSIA','STROVOLOS','PANAYIAS','12',2682,TO_DATE('01.01.1989', 'DD.MM.YYYY'),5000,9999999,1);
INSERT INTO EMPLOYEE VALUES (1235,'KOSTAS', 'KOSTA', 'MALE', 'NICOSIA','STROVOLOS','VIZANTIOU','12',2064,TO_DATE('01.02.1980', 'DD.MM.YYYY'),5000,9999998,2);
INSERT INTO EMPLOYEE VALUES (1236,'MARIA', 'ANTREOU', 'FEMALE', 'NICOSIA','EGKOMI','TSAROU','12',2522,TO_DATE('05.05.1988', 'DD.MM.YYYY'),5000,9999995,3);
INSERT INTO EMPLOYEE VALUES (1237,'GEORGIA', 'ANTREOU', 'FEMALE', 'NICOSIA','EGKOMI','TSAROU','13',2522,TO_DATE('05.05.1978', 'DD.MM.YYYY'),5000,9999996,4);
INSERT INTO DEPARTMENT VALUES ('SERVICE',1,1234);
INSERT INTO DEPARTMENT VALUES ('SALES',2,1235);
INSERT INTO DEPARTMENT VALUES ('ACCOUNTING',3,1236);
INSERT INTO DEPARTMENT VALUES ('MANAGEMENT',4,1237);
INSERT INTO CUSTOMER VALUES (4321, 'ANTREAS', 'ANTREOU','MALE','PAFOS','GEROSKIPOU','VIZANTIOU','3',2525,TO_DATE('04.04.1954','DD.MM.YYYY'));
INSERT INTO CUSTOMER VALUES (4322, 'MARIA', 'ANTREOU','FEMALE','PAFOS','GEROSKIPOU','VIZANTIOU','7',2525,TO_DATE('03.03.1953','DD.MM.YYYY'));
INSERT INTO CUSTOMER VALUES (4323, 'KOSTAS', 'ANTREOU','MALE','PAFOS','GEROSKIPOU','VIZANTIOU','3',2525,TO_DATE('04.04.1970','DD.MM.YYYY'));
INSERT INTO CUSTOMER VALUES (4324, 'ELENA', 'ANTREOU','MALE','PAFOS','GEROSKIPOU','VIZANTIOU','3',2252,TO_DATE('04.04.1985','DD.MM.YYYY'));
INSERT INTO CUSTOMER VALUES (4325, 'MARIOS', 'ANTREOU','MALE','PAFOS','GEROSKIPOU','VIZANTIOU','3',2525,TO_DATE('04.04.1987','DD.MM.YYYY'));
INSERT INTO CAR VALUES (1111111111, 'MAZDA', '3', 'BLUE', 'MANUAL', 'PETROL', 1600, TO_DATE('08.01.2013','DD.MM.YYYY'), 5000, 'CASH', 2, 4321);
INSERT INTO CAR VALUES (2222222222, 'TOYOTA', 'COROLLA','BLACK', 'MANUAL','PETROL',1600,TO_DATE('08.01.2013','DD.MM.YYYY'),7000,'FINANCE',2,4322);
INSERT INTO CAR VALUES (3333333333, 'TOYOTA', 'HILUX', 'GRAY', '4X4', 'DIESEL', 2500, TO_DATE('08.01.2013','DD.MM.YYYY'), 10000, 'CASH', 2 , 4325);
INSERT INTO CAR VALUES (4444444444, 'HONDA', 'CIVIC', 'BLACK', 'MANUAL', 'PETROL', 1300, TO_DATE('08.01.2013','DD.MM.YYYY'), 3000,'CASH', 2, 4323);
INSERT INTO CAR VALUES (5555555555, 'HONDA', 'INSIGHT', 'WHITE', 'AUTO', 'PETROL', 1500, TO_DATE('08.01.2013','DD.MM.YYYY'), 20000, 'FINANCE', 2, 4324);
INSERT INTO CAR_PARTS VALUES ('A20005B', 'RIGHT FRONT AXLE', 200);
INSERT INTO CAR_PARTS VALUES ('C15220C', 'AIR FILTER', 50);
INSERT INTO CAR_PARTS VALUES ('V99T', 'ENGINE GASKET', 80);
INSERT INTO CAR_PARTS VALUES ('A20004B', 'LEFT FRONT AXLE', 200);
INSERT INTO CAR_PARTS VALUES ('U9P002', 'INTAKE MANIFOLD', 300);
INSERT INTO USED_CAR VALUES (4444444444, 25000, TO_DATE('02.02.2000','DD.MM.YYYY'));
INSERT INTO USED_CAR VALUES (5555555555, 122000, TO_DATE('05.08.2003','DD.MM.YYYY'));
INSERT INTO SERVICE VALUES (TO_DATE('12.01.2013','DD.MM.YYYY'), TO_DATE('01.01.2013','DD.MM.YYYY'), 300, 0001, 4321, 'CASH', 1111111111);
INSERT INTO CUST_PHONUMBER VALUES (99123456, 4321, 'MOBILE');
INSERT INTO CUST_PHONUMBER VALUES (99849563, 4322, 'MOBILE');
INSERT INTO CUST_PHONUMBER VALUES (22568988, 4323, 'LANDLINE');
INSERT INTO CUST_PHONUMBER VALUES (25698974, 4324, 'LANDLINE');
INSERT INTO CUST_PHONUMBER VALUES (97584692, 4325, 'MOBILE');
INSERT INTO CAR_DEFECTS VALUES ('BROKEN SIDE MIRRORS|OIL LEAKS', 4444444444);
INSERT INTO CAR_DEFECTS VALUES ('RUSTY PAINT|WORN-OUT CLUTCH', 5555555555);
INSERT INTO EMPLOYEE_PHONUMBER VALUES (97989565, 1234);
INSERT INTO EMPLOYEE_PHONUMBER VALUES (97585858, 1235);
INSERT INTO EMPLOYEE_PHONUMBER VALUES (96525263, 1236);
INSERT INTO EMPLOYEE_PHONUMBER VALUES (97484852, 1237);
INSERT INTO SERVICE_DETAILS VALUES (0001, 'BROKEN FRONT RIGHT AXLE', 'REPLACED FRONT RIGHT AXLE');
INSERT INTO HAS VALUES ('A20005B', 1111111111);
INSERT INTO HAS VALUES ('A20004B', 1111111111);
INSERT INTO USES VALUES ('A20005B', 0001);