· 4 years ago · Apr 11, 2021, 01:26 PM
1Drop Schema if exists phonebook;
2Create Schema phonebook;
3Use phonebook;
4
5Create Table Person (
6 Id Varchar (5) Primary Key Not Null,
7 Pname Varchar(40),
8 DOB Date,
9 Paddress Varchar (100));
10
11Create Table Tel (
12 Pid Varchar(5),
13 Tserial Varchar (3),
14 Telno Varchar (15),
15Constraint pk Primary Key (Pid, Tserial),
16Constraint fk Foreign Key (Pid) references Person (Id));
17
18Insert into Person values (1,'john','1970-01-03','5 shore st.' );
19Insert into Tel values (1,1,'03-2245655' );
20Insert into Tel values (1,2,'012-6453242' );
21Insert into Person values (2,'mark','1967-07-08','5 shore st.' );
22Insert into Tel values (2,1,'03-8644353' );
23
24Select Id, Pname, DOB, paddress, Tserial, Telno
25from Tel , Person
26where Pid = Id;
27
28SELECT * FROM phonebook.person;
29SELECT * FROM phonebook.tel;