Street (name, location, city)

Q. Consider the following relations with keys underlines-
Street (name, location, city)
House (number, street_name)
Lives (name, house_number)
Define the above relations as tables in DDL SQL making real world assumptions about the type of the fields. Define the primary keys and the foreign keys.

Solution:

Table for relation “Street (name, location, city)” is-
create table Street
(name varchar2 (25) not null,
location varchar2 (28),
city varchar2 (20),
primary key (name));

Table for relation “House (number, street_name)” is-
create table House
(number int not null,
street_name varchar2 (25) not null,
primary key (number),
foreign key (street_name) references Street (name));

Table for relation “Lives (name, house_number)” is-
create table Lives
(name varchar2 (25) not null,
house_number int not null,
primary key (name),

foreign key (house_number) references House (number));

Related topics

Professor Jayesh video tutorial

Please use contact page in this website if you find anything incorrect or you want to share more information about the topic discussed above.