Professional Documents
Culture Documents
Base01 Create Tables
Base01 Create Tables
Base01 Create Tables
CREATE TABLES
FIELD TYPE
INTEGER
INTEGER Most common. Values up to 10 digits.
TINYINT Between -128 y 127.
BIGINT Up to 19 digits.
SMALLINT Between -32.768 and 32.767
TEXT
CHAR Up to 255 char.
VARCHAR Up to 32700 char. caracteres como máximo,
número de caracteres es variable, es
aconsejable para un campo como puede ser
Observaciones
BOOLEAN (YES/no)
Yes/No Values that can be
[ BOOLEAN ]
DATE
DATE Date
TIMESTAMP Date and time.
EXERCISE 1
• Create a Database with the name Agenda_YourName to store
data of personal contacts.
• In the database create the table CONTACTS with the following
fields:
EXERCISE 2
Create a database with the name Library_YourName. Create the
following table in it with the name USERS. The primary key must be
the user_number field.
USERS TABLE
FIELD FIELD TYPE
User _code Autonumerical Primary key
Name Text Required
Surname Text
Phone Text
Birthdate Date
Sanctioned Yes/No Default No
COUNTRIES TABLE
FIELD FIELD TYPE
Country_code Autonumerical Primary key
Name Text Required
Surface Float
AUTHORS TABLE
FIELD FIELD TYPE
Autor_code Autonumerical Primary key
Name Text Required
Country Integer
BOOKS TABLE
FIELD FIELD TYPE
Book_code Autonumerical Primary key
Name Text Required
Author Integer
Title Text
Number of pages A number
LENDINGS TABLE
FIELD FIELD TYPE
lending_code Autonumerical Primary key
User Integer Required
book Integer Required
date_lending Date Required
date_return Date
Exercise 4
• Create a database called futbol_YOURNAME. It has Information
about (3 tables):
◦ Football players.
◦ Football clubs
◦ National Teams.
• Add the fields that you consider necessary (you have freedom,
so be careful not to repeat with your classmates).
• We also have the following information to store with
relationships (and one table).
◦ A player belongs to a national team and can never change.
◦ A player belongs now to a club.
◦ But we also have the information of all the clubs he has
belonged to before.
• Add about 3-5 records to each table.