You are on page 1of 9

19/09/2022

Business Intelligence

2. All around a database

Prof Dr Charles Ducrocq

Exercise: table customer


in a table “Customer”, create fields which must appear as master
data (permanent data concerning a customer)

CUSTOMER

33

1
19/09/2022

Exercise: table customer


in a table “Customer”, create fields : idea for starting the solution

CUSTOMER
Customer number
Customer name

Customer number Customer name …



1234 Society Delta
the customer Delta
… has 2 numbers
2345 Society Delta
… 34

Fiscal enterprise number : SIREN in France


Each enterprise has a specific id given by a National Administration.
In France, this id is composed of two numbers : the enterprise number (SIREN) with 9
digits and the division number (SIRET) with 14 digits for more detail in a group
(different agencies in a bank, different factories in an industrial firm, different shops in
a group, different supermarkets…).
Example : SIREN number 732 829 320 (the 9th digit is a control key to find)
To control this SIREN number : 7 3 2 8 2 9 3 2 0
Digit on each even column x 2 : 6 16 18 4
Digit on each odd column x 1 : 7 2 2 3 0
Sum of these new digits : 7+6+2+(1+6)+2+(1+8)+3+4+0 = 40 (sum = 4 tens : OK)
Example : SIRET number for the 0007th factory of this society 732829320
To control : 7 3 2 8 2 9 3 2 0 0 0 0 7 4 (the 14th digit is a control key to find)
Digit on each even column x 1 : 3 8 9 2 0 0 4
Digit on each odd column x 2 : 14 4 4 6 0 0 14
Sum of these digits: (1+4)+3+4+8+4+9+6+2+0+0+0+0+(1+4)+4=50 (sum = 5 tens OK)

The European VAT number : FR 33 732829320 2 country letters, 11 digits


for France: 2 digits and the SIREN code

You can consult real societies’SIRET numbers on www.societe.com


35

2
19/09/2022

Exercise: table customer


in a table “Customer”, create fields : idea for a “dangerous” solution

CUSTOMER
Customer number
Customer fiscal code
Customer name
Street & Number
Zip code
Customer city
Customer country
Customer phone

36

Impossibility to realize a query


It’s necessary to avoid to introduce several times the same data

Customer_id Customer_name Customer_city …


1231 Alpha Clermont-Ferrand
1232 Beta Clermond-Ferrant
1233 Gamma Clermond-Fd
1234 Delta Clermont_Ferand
1235 Epsilon Clermond Ferand
1236 lambda Clermont Ferant

Main key
To be transformed in
a foreign key
37

3
19/09/2022

Main key – Foreign key

City_id City_name
Main key Foreign key
Primary key Secondary key 163 Clermont-Ferrand

Link, joint
Customer_id Customer_name City_id … between two
1231 Alpha 163 tables

1232 Beta 163


1233 Gamma 163
1234 Delta 163
1235 Epsilon 163
1236 lambda 163
… 38

Link and cardinalities between two tables

CUSTOMER
Customer_id
Customer_name
CITY …
1,n 1,1
City_id City_id
City_name …
… …
Cardinality 1,n : Cardinality 1,1 :
in a city, the society a customer with a
has one customer specific address
or more (2, 3, …n) belongs to one city
and only one
39

4
19/09/2022

Exercise: table customer


in a table “Customer”, create fields : better and better solution

CUSTOMER
Customer_id
Fiscal_code
Customer_name
address1
address2
City_id
Country
Phone
Customer_contact
Our_vendor
Activity_sector 40

Solution: table customer

COUNTRY CUSTOMER
Country_id Customer_id
Country_name Fiscal_code
Customer_name
address1
CITY address2
City_id City_id
City_name Phone
Country_id www
Customer_contact
Joint with a table Vendor
Vendor_id
Joint with a table Activity_sector Activity_sector_id 41

5
19/09/2022

Joints and cardinalities between tables

Table : Article
Table : Family_art
article article Catalog family 1,1 1,n Family Family
_id description price _id _id description
12345 shirt relax 6,80 44 43 T-shirt/polo shirt
12346 shirt relax 6,10 44 44 Shirt/jumper
12348 shirt city 7,40 44 45 Sweater

Main key description Foreign Main


= = key key
uniqueness clearness, =
= legibility
Used by Link with
= the main columns : fields
computer Used by lines : recordings
scientists, key of an
managers other table
administrators of 42
a data base

Exercise : joins between tables


Insert joins and cardinalities (1,1 or 1,n) between the tables

43

6
19/09/2022

Solution : joins between tables

No link between
these tables, no
query possible

44

Create a flow for an order

Insert tables and fields which are necessary to register an order of articles
from customers

45

7
19/09/2022

Create a flow for an order


Be careful: it’s necessary to separate order (the top, the head of the
document) and order_line (the down part, the detail of the document)

46

Solution

47

8
19/09/2022

Global flow order-delivery-invoice


Complete the tables concerning order, delivery and invoice

48

Les tables de la fonction Vente reliées entre elles

49

You might also like