martes, 23 de octubre de 2012

BASE DE DATOS PARA EL PROYECTO 2DO PARCIAL

REVISAR Y CREAR ESTE SCRIPT EN LA BD MYSQL
mysql> USE Inventario;

Database changed
mysql> CREATE TABLE Articulo(
-> claveArt varchar(10) not null,
-> descripcion varchar(35),
-> precio numeric(2,1),
-> existencia int,
-> PRIMARY KEY(claveArt)
-> );
Query OK, 0 rows affected (0.12 sec)

mysql> CREATE TABLE MovArticulo(
-> folio int not null,
-> fecha DATE,
tipoMov CHAR(1),
-> cantidad int,
-> claveArt varchar(10),
-> PRIMARY KEY(folio),
-> FOREIGN KEY (claveArt)
-> REFERENCES Articulo(claveArt)
-> );
Query OK, 0 rows affected (0.14 sec)

mysql> SELECT *FROM Articulo;
Empty set (0.00 sec)

mysql> INSERT INTO Articulo (
-> claveArt,descripcion,precio, existencia)
-> VALUES
-> ("001","Coca-Cola",6.5,100);
Query OK, 1 row affected (0.02 sec)

mysql> SELECT *FROM Articulo;
+----------+-------------+--------+------------+
| claveArt | descripcion | precio | existencia |
+----------+-------------+--------+------------+
| 001 | Coca-Cola | 6.5 | 100 |
+----------+-------------+--------+------------+
1 row in set (0.00 sec)

mysql> INSERT INTO Articulo (
-> claveArt,descripcion,precio, existencia)
-> VALUES ("002","Pepsi-Cola",6.2,100);
Query OK, 1 row affected (0.05 sec)

mysql> SELECT *FROM Articulo;
+----------+-------------+--------+------------+
| claveArt | descripcion | precio | existencia |
+----------+-------------+--------+------------+
| 001 | Coca-Cola | 6.5 | 100 |
| 002 | Pepsi-Cola | 6.2 | 100 |
+----------+-------------+--------+------------+
2 rows in set (0.00 sec)

mysql> INSERT INTO MovArticulo
-> (folio,fecha,tipomov,cantidad,claveArt)
-> VALUES(1,"2012-10-23",'E',12,"002");
Query OK, 1 row affected (0.06 sec)

mysql> SELECT *FROM MOVARTICULO;
+-------+------------+---------+----------+----------+
| folio | fecha | tipoMov | cantidad | claveArt |
+-------+------------+---------+----------+----------+
| 1 | 2012-10-23 | E | 12 | 002 |
+-------+------------+---------+----------+----------+
1 row in set (0.00 sec)

mysql> SELECT *FROM ARTICULO;
---------+-------------+--------+------------+
| claveArt | descripcion | precio | existencia |
+----------+-------------+--------+------------+
| 001 | Coca-Cola | 6.5 | 100 |
| 002 | Pepsi-Cola | 6.2 | 100 |
+----------+-------------+--------+------------+
2 rows in set (0.00 sec)

mysql>

No hay comentarios:

Publicar un comentario en la entrada