database-design

Database Designing: An art or headache (Managing relationships)

廉价感情. 提交于 2020-01-22 14:32:02
问题 I have seen in my past experience that most of the people don't use physical relationships in tables and they try to remember them and apply them through coding only. Here ' Physical Relationships ' refer to Primary Key , Foreign Key , Check constraints , etc. While designing a database, people try to normalize the database on paper and keep things documented. Like, if I have to create a database for a marketing company, I will try to understand its requirements. For example, what fields are

Database Designing: An art or headache (Managing relationships)

余生颓废 提交于 2020-01-22 14:31:36
问题 I have seen in my past experience that most of the people don't use physical relationships in tables and they try to remember them and apply them through coding only. Here ' Physical Relationships ' refer to Primary Key , Foreign Key , Check constraints , etc. While designing a database, people try to normalize the database on paper and keep things documented. Like, if I have to create a database for a marketing company, I will try to understand its requirements. For example, what fields are

Primary key for multiple column in PostgreSQL?

流过昼夜 提交于 2020-01-22 11:46:26
问题 How to provide primary key for multiple column in a single table using PostgreSQL? Example: Create table "Test" ( "SlNo" int not null primary key, "EmpID" int not null, /* Want to become primary key */ "Empname" varchar(50) null, "EmpAddress" varchar(50) null ); Note: I want to make "EmpID" also a primary key. 回答1: There can only be one primary key per table. That's what the word "primary" hints at. You can have additional UNIQUE columns. CREATE TABLE test( sl_no int PRIMARY KEY, -- NOT NULL

Primary key for multiple column in PostgreSQL?

老子叫甜甜 提交于 2020-01-22 11:45:27
问题 How to provide primary key for multiple column in a single table using PostgreSQL? Example: Create table "Test" ( "SlNo" int not null primary key, "EmpID" int not null, /* Want to become primary key */ "Empname" varchar(50) null, "EmpAddress" varchar(50) null ); Note: I want to make "EmpID" also a primary key. 回答1: There can only be one primary key per table. That's what the word "primary" hints at. You can have additional UNIQUE columns. CREATE TABLE test( sl_no int PRIMARY KEY, -- NOT NULL

Normalize or Denormalize in high traffic websites

浪子不回头ぞ 提交于 2020-01-22 05:30:50
问题 What are the best practices for database design and normalization for high traffic websites like stackoverflow? Should one use a normalized database for record keeping or a normalized technique or a combination of both? Is it sensible to design a normalized database as the main database for record keeping to reduce redundancy and at the same time maintain another denormalized form of the database for fast searching? or Should the main database be denormalized but with normalized views at the

Design logical model of Datawarehouse, Fact Tables and Dimensions Table

孤者浪人 提交于 2020-01-22 02:13:10
问题 Hi i'm newbie in Datawarehousing,For homework ask me realize the logical design, physical and implementation.How would you model this in a Data Warehouse: i wish design the Data Warehouse which give the answers of statistics relating to a baseball league For players in offensive: •How many times has a batter to bat. •How many runs scored is. •How many hits,doubles hit and triples hits. •How many homeruns did. •many RBI. •many base on balls in Defensive: ▪ How many outs, double play takes ▪

Can Firebase Realtime Database effectively loop through billions of posts and retrieve them by the users that posted them?

纵饮孤独 提交于 2020-01-22 02:00:42
问题 I am developing an iOS app with Firebase Realtime Database. The app will potentially have billions of posts with a number of images and data that needs to be retrieved based on the people a specific user follows (something like Instagram). I understand that the best practice in Firebase is to structure data as flat as possible which would mean having a "Posts" node with potentially billion of entries, which I would then filter by a kind of 'posted_by' parameter. This begs two questions: 1)

How can I relate a primary key field to multiple tables?

血红的双手。 提交于 2020-01-21 18:54:27
问题 I have 4 tables: User Reports Photos Locations I am allowed to report photos, users, and locations. The primary key of my Reports table is ( User_Id, Reported_Id ) Reported_Id could belong to any of these 3: photos , users and locations . How can I represent this relationship in an entity relationship model? 回答1: The Problem You cannot do this - a foreign key (Reported_Id) cannot reference three tables at once Seems to be a problem regarding the understnading of the data ... rather than a

How can I relate a primary key field to multiple tables?

☆樱花仙子☆ 提交于 2020-01-21 18:54:20
问题 I have 4 tables: User Reports Photos Locations I am allowed to report photos, users, and locations. The primary key of my Reports table is ( User_Id, Reported_Id ) Reported_Id could belong to any of these 3: photos , users and locations . How can I represent this relationship in an entity relationship model? 回答1: The Problem You cannot do this - a foreign key (Reported_Id) cannot reference three tables at once Seems to be a problem regarding the understnading of the data ... rather than a

Designing relationships around an inheritance structure

坚强是说给别人听的谎言 提交于 2020-01-21 05:45:08
问题 I have a conceptual question regarding how best to organise my database. Currently I have four core tables users , teachers , students and notifications . However both the teachers and students tables inherit from the users table so contain the foreign key user_id . The notifications table as you might have guessed refers to notifications. These need to appear for all users that belong to an employee group i.e. under the employment of another. Both students and teachers can employ other users