I'm using mysql and phpmyadmin to create a video rental database and I've been having problems with the auto_increment feature and the numeric data type. I have auto_increment on multiple tables for their table id's. The problem is when i enter data into the tables the counter doesnt reset. So if I enter 4 actors their id's would be 1,2,3,4 but then when i enter in data for the customers the count starts where the last table left off so if i enter 4 customers their id's come up as 5,6,7,8 when they should be 1,2,3,4.
My problem with the numeric data type is when ever i enter anything into that field it always shows up as .99 unless i enter something lower than .99 then it works fine but if i try to enter 3 or 3.00 it come up as .99. I think i might not have declared it right by I'm not sure. I've also tried decimal and it did the same thing.
These are my tables.
create table actor
( actor_id int not null auto_increment,
first_name varchar(20),
last_name varchar(20),
primary key (actor_id)
) ENGINE = InnoDB;
create table customer
( customer_id int not null auto_increment,
first_name varchar(20),
last_name varchar(20),
phone_number varchar(20),
email varchar(50),
primary key(customer_id)
) ENGINE = InnoDB;
create table movie
( movie_id varchar(10),
title varchar(50),
release_year numeric(4,0),
rental_duration tinyint,
rental_rate numeric(2,2),
rating varchar(5),
genre varchar(20),
stock int,
primary key (movie_id)
) ENGINE = InnoDB;
create table movie_actor
( actor_id int,
movie_id varchar(10),
foreign key (actor_id) references actor (actor_id),
foreign key (movie_id) references movie (movie_id)
) ENGINE = InnoDB;
create table rental
( rental_id int not null auto_increment,
rental_date date,
customer_id int,
return_date date,
primary key (rental_id),
foreign key (customer_id) references customer (customer_id)
) ENGINE = InnoDB;
create table payment
( payment_id int not null auto_increment,
customer_id int,
rental_id int,
amount numeric(2,2),
payment_date date,
primary key (payment_id),
foreign key (customer_id) references customer (customer_id),
foreign key (rental_id) references rental (rental_id)
) ENGINE = InnoDB;
This is the file I used to enter the starting data into the tables
delete from actor;
delete from customer;
delete from movie;
delete from movie_actor;
delete from payment;
delete from rental;
insert into actor values ('null', 'Bradley', 'Cooper');
insert into actor values ('null', 'Ed', 'Helms');
insert into actor values ('null', 'Zach', 'Galifianakis');
insert into actor values ('null', 'Leonardo', 'DiCaprio');
insert into actor values ('null', 'Ben', 'Kingsley');
insert into actor values ('null', 'Mark', 'Ruffalo');
insert into actor values ('null', 'Denzel', 'Washington');
insert into actor values ('null', 'Will', 'Patton');
insert into customer values ('null', 'Bob', 'Smith', '330-678-2732', 'Smith22@live.com');
insert into customer values ('null', 'Steve', 'Johnsan', '330-238-2342', 'sjohn@live.com');
insert into customer values ('null', 'Amy', 'Davis', '330-283-8392', 'davis47@live.com');
insert into customer values ('null', 'Elizabeth', 'Veres', '330-687-8941', 'everes@live.com');
insert into customer values ('null', 'Jacob', 'Funchion', '419-966-6617', 'jfunchio@kent.edu');
insert into movie values ('mov-00001', 'The Hangover', '2009', '5', '3.00', 'R', 'Comedy', '5');
insert into movie values ('mov-00006', 'Beauty and the Beast', '1991', '5', '300', 'G', 'Family', '5');