-----------------------------------------
--1.

select * from sys.databases
where name='AdventureWorksOBP'
-- 2018-09-14 09:27:07.627

-----------------------------------------
--2.

select * from sys.columns
where object_id=789577851
-- IDKupac, Ime, Prezime

select * from sys.tables
where name='kupac'
-- object_id=789577851

select * from sys.columns
where object_id=
(
	select object_id from sys.tables where name='kupac'
)
-- IDKupac, Ime, Prezime
-----------------------------------------
--3.

select name, count(*)
from sys.columns
group by name
order by 2 desc
-- 'status'
-----------------------------------------
--4.

select * from sys.tables
where name='proizvod'
-- Proizvod object_id=757577737

select *
from sys.key_constraints
where parent_object_id=757577737

-- PK_Proizvod
-----------------------------------------
--5.

select *
from sys.tables
-- Racun object_id=821577965

select *
from sys.foreign_keys as fk
where fk.parent_object_id=821577965
-- FK_Racun_Komercijalist vodi na referenced_object_id=629577281
-- FK_Racun_KreditnaKartica vodi na referenced_object_id=597577167

select * from sys.tables where object_id=629577281
-- Komercijalist

select * from sys.tables where object_id=597577167
-- KreditnaKartica
-----------------------------------------