Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Star Schema

Author  Topic 

toseef_asim
Starting Member

1 Post

Posted - 2012-06-05 : 04:00:32
Write SQL statements to construct the "Star Schema" given.
Guide lines: Use appropriate data types for the table attributes.
Show the Primary/Foreign key constraints.
Please Check the code written is correct or not.

Create table Account_holder (
Account_holder_id int primary key,
Name varchar(100),
NIC_no int,
Address varchar(300),
Phone_no int,
Email varchar(100)

)

Create table account (
Account_ID int PRIMARY KEY,
Account_name varchar(100),
Account_type varchar(50),
Account_no int,
Profit_rate int
)



create table savings (
Account_holder_ID FOREIGN KEY REFERENCES Account_holder(Account_holder_id),
Account_ID int FOREIGN KEY REFERENCES Account (Account_ID),
Time_ID int FOREIGN KEY REFERENCES Time (Time_ID),
Bank_ID int FOREIGN KEY REFERENCES Bank (Bank_ID),
Saving int PRIMARY KEY
)


create table time (
Time_ID int PRIMARY KEY,
Date datetime,
Week int,
Month varchar(100),
Quarter int,
Year varchar(100)
)


create table Bank (
Bank_ID int PRIMARY KEY,
Bank_name varchar(250),
Branch_name varchar(250),
Town varchar(50),
City varchar(50),
Zone varchar(50),
Province varchar(50)
)

Please Check the code and identify errors.
regards
Toseef asim
toseef_asim@yahoo.com

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-05 : 04:31:10
Star schema is often just a fact table with keys referencing all the dimensions - which is what yoou have.
Would expect there to be a measure on the savings table.
Would expect an amount if you are recording transactions. Maybe a transaction type too.
Could just be the total with the last time it is updated though.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -