Base01 Create Tables

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

BASE.

CREATE TABLES

You can found hundreds of tutorials in youtube just


typing LIBREOFFICE BASE TUTORIAL

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

NUMBERS WITH DECIMAL POINT


NUMERIC For currency. We have to specify the number
of integer and decimal digits.

FLOAT Real number for science and mesures.


DOUBLE Same as FLOAT but with bigger numbers

BINARY AND IMAGES


LONGVARBINARY For images

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:

FIELD Data Type

Id_contact Integer Primary key. Automatic value.

name Text mandatory, size 50.

surname Text Max size 100 char.

telephone Text Size 9 char. ¿Why not a number?

Money that owns Number Size 10 and 2 decimal digits.


me with
decimals

BFF (best friend yes/no Default value is no


forever)
Birth date date Mandatory

Adress text Máximo 60 caracteres.

nickname text Optional. Default value


“Nonickname”

 Write the data of 5 contacts.


 Sort the data by Surname.
 Filter the data so you can only see the BFF.

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

DATA BASE RELATIONSHIPS


Exercise 3
Create the following relationships, marking update and
delete actions with “No Action”.

Enter 3 records from each table (after adding the


relationships. Check what happens when we enter codes
that do not exist, for example a user number that does
not exist in the lendings table)
Exercise 3
• Create a database called animals_YOURNAME. It has
Information about (3 tables):
◦ Animals
◦ Species
◦ Continents
• 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)
◦ An animal is of one specie (many to one)
◦ An specie can be from more than one continent (many to
many).
• Add about 2-3 records to each table.

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.

You might also like