database design process?
1 - define purpose of database(university)
-
2-find information required(student table and department table informations beside them like how many departments the uni have or faculty)
--
3-create field and tables and primary keys
--
4 = create relationships between tables
--
5-normalaize the design
normalazation rules:
1nf 2nf 3nf
first normal form // //
first rule of normalization?
make fields separately not such as
first and second name in one field
second rule of normalization ?
u have to make sure that every non primary key field depends on primary key field
normalization 3rd rule?
2 and 1should be done then
the non primary key fields should be independent on each other
how can we make relationship between two tables?
a head of primary key in one table will be a tail of foreign key in other table
three types of relationships :
one to one
one to many
many to many
one to one relatioship will be between which table and which table?
between one stuff which has one stuff
one student has one contact
which contact contains house number
id also passport if needs
one to one example?
one car has a one id and license car and model
which relationship is most common?
one to many
why relationships are useful?
cus they free us from repeatin datas in tables
for one to one what is the condition to make relationship and also what is it for one to many ?
one to one both should be primary key
student id --> student id
one to many one of them needs to be primary key
costumer id --> position of student will be foreign key
what is diff between foreign key and primary key?
u can't update anything from foreign key but in primary , its ok
how does one to many works?
one costumer can order many things(which all of them have diff id)
costumer table is parent
and order table is child table
how does many to many works?
a book can be written by many writers
and a writer can write many books
so we need third table which contains
writer id
book id
and an id for book_and_writer table as primary key
sql and mysql can do what?
creating table removing table insetrt data retrieve data